• PkSharma
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 10
    Replies

Hi,

 

I have a custom object "xyz" with a look up field to accounts

 

We need to see the name of the account owner, I cannot get it via formula (well, I could, but then I would need to modify the formula each time a new user is created and TEXT( Account__r.Ownership ) didn´t work)

 

I guess this is a simple trigger, to get the account owner name populated in the "xyz" object...

 

 

Any sample trigger you may have please to direct me to the right direction....

 

Thank you!!:) 

 

  • November 04, 2011
  • Like
  • 0

Hi,

 

I have a custom object "xyz" with a look up field to accounts

 

We need to see the name of the account owner, I cannot get it via formula (well, I could, but then I would need to modify the formula each time a new user is created and TEXT( Account__r.Ownership ) didn´t work)

 

I guess this is a simple trigger, to get the account owner name populated in the "xyz" object...

 

 

Any sample trigger you may have please to direct me to the right direction....

 

Thank you!!:) 

 

  • November 04, 2011
  • Like
  • 0

Hi,

 I have a class that enters values(from a lookup) in AccountTeamMember object from a custom visualForce page.There are 3 main parametres that are supposed to be entered

1.AccountName(Look up)

2.UserName(Look up)

3.TeamMemberRole(dropdown)

The method is given below:

 public void save(){
   try
    {      
       if (accTeamMem == null)  
                      {      
                        accTeamMem = new AccountTeamMember(); 
                       } 
      String accountID =  ApexPages.currentPage().getParameters().get('searchAccount');
      String UserID  =  ApexPages.currentPage().getParameters().get('searchName');  
      String teamMemberRole = ApexPages.currentPage().getParameters().get('searchRole');     
      system.debug('accountid ='+accountID );
     system.debug('accountid ='+UserID );
     // system.debug('accountid ='+teamMemberRole );      
      insert accTeamMem;   
    }
     Catch (DMLException e) { 
       ApexPages.addMessages(e);      
        }   
          
        //return null;
     LoadData();
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Your entry has been added')); 

        }        
Custom controller used:  TeamMemberAssignmentController 

I wanna write a test class for this method, so far this is what i've done:

 

 

@isTest
private class TestTeamMemberAssignmentController    {

static testMethod void runTest() {
User u = [Select id,name from User where id = :UserInfo.getUserID()];
        ApexPages.currentPage().getParameters().put('searc​hAccount','a2');
        ApexPages.currentPage().getParameters().put('searc​hName','u.id');
        ApexPages.currentPage().getParameters().put('searc​hRole','Account Manager');
        
        TeamMemberAssignmentController c = new TeamMemberAssignmentController();
        
        c.save(); 
}
}

This is showing "insert failed" error u.id and a2 are not getting inserted.Please help me,this is my first test class!!!!

Thanks

I have a trigger that works fine, but I have a SOQL query within a for loop. I know this is not a good idea because of APEX governer limits but I can't figure out what the syntax will be if I move it outside of the loop. Sales_Person_On_Record__c is a user lookup field. 

 

Within the for loop I am able to use op.field_name, and I'm not sure how I would use that outside the for loop. Any help would be appreciated. 

 

trigger SalesPersonOnRecord on Opportunity (before insert, before update) {
	
	for( Opportunity op : Trigger.new ) {
		String spadName; //Sales Person Associated with Deal
		String ownerName; //Name of the Opportunity Owner
		
                spadName = [select id, name from user where id = :op.Sales_Person_Associated_with_Deal__c limit 1].name;
		
		//Get the name of the opportunity owner
		ownerName = [select id, name from user where id = :op.ownerid limit 1].name;

                //Rest of the code is excluded since I only need help with the queries
      }
}

 

I am trying to integrate my Apex code with a .Net webservice method.

My Apex class should query for a list of records and pass them to the .Net Webservice method.(How can i pass the list of records retrived). 

And the list is performed with a certain operation it should be passed back to Apex method for certain updates.

 

Can any one please provide me with an example for this integration with .Net web service.

 

Than you.

  • September 20, 2011
  • Like
  • 0

I have a custom link on a custom object Customer, which is an on click Javascript.

 

This link redirects to a new record page of another object MM Account based on some condition, and it pre-populates Customer.name in a field on the redirected page. 

Following is the code for the button:

 

if( (({!Customer__c.MMAccountHolder__c}) == false) )
{
	var str = '{!Customer__c.Name}';
	str.replace("\"", "\\\"");
	window.location="/a0B/e?retURL={!Customer__c.Id}&00NA0000006AZ4u={!Customer__c.Customer_Number__c}&CF00NA0000006AZ4p="+str+"";
}
else
{
             window.location="/{!Customer__c.MMid__c}";
}

 It works fine when usually, but whenever there is a single quote in the customer name, it gives a javascript error, "expected ; "

 

I have in past, handled double quote, but cant seem to handle the single quote.

 

Can anyone please look into this.

 

Thanks for any help.

 

~Sumit

  • September 19, 2011
  • Like
  • 0

Hi all,

 

How to get the manager name of the user. ?

 

userList1 = [ select id, name, firstname, lastname,ManagerId from user where Managerid =: Userinfo.getUserId() ];

 

Pls help.

 

 

Thanks in advance.

  • September 16, 2011
  • Like
  • 0

Hi,

 

I'm trying to invoke a webservice created in one salesforce org from another salesforce org. When we try to import the wsdl generated from apex class to the other org, the parser throws exceptions.

 

Any pointers in this direction will be of great help.

 

Thanks & Regards,

Sreedhar

Can anybody tell me how to add calendar on visualforce page... 

  • September 15, 2011
  • Like
  • 0

I am trying to Accounts with following dynamic soql :

 

 query= 'select Account_vod__c,Account_vod__r.Id,Account_vod__r.Name,Address_line_2_vod__c,'+
                      'City_vod__c,Name,Primary_vod__c,State_vod__c,Zip_vod__c from Address_vod__c where '+
                      'Account_vod__r.Name like \'%'+searchByName+'%\' OR City_vod__c=\''+searchByCity+'\' OR '+
                      'State_vod__c=\''+searchByState+'\' OR Zip_vod__c=\''+searchByZip+'\' OR Name=\''+searchByAddressLine1+'\' AND NOT IN : accIds';


 

in this accIds is a List of Account Ids which i want to exclude from the return record list. but for this NOT IN Clause is not working. I am getting a query exception for this perticular line .  How to solve this problem.

 

Please help me in this regard, as it is kind of urgent for me.

  • September 15, 2011
  • Like
  • 0