+ Start a Discussion
rosscorossco 

Custom Button URL and related record values

Hi

 

I have a custom object A that has a lookup to an Opportunity via field B. That opportunity has a custom field called C that is a lookup to Contact.  I now want to put a custom button on object A that passes the value of the contact id (on the opportunity) to an apex page. How do I specify this in the Custom Button URL?

 

Thanks

Ross

 

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,



I have created a custom object with the lookup field opportunity. I have also created a lookup field in opportunity object with contact object.


After that create a formula field “testfield “ name in custom object with text type with following formula.
fieldB__r.Fieldc__c


Now create a custom button in custom object with following
Content Source=URL


/apex/pagename?id= testfield__c

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,



I have created a custom object with the lookup field opportunity. I have also created a lookup field in opportunity object with contact object.


After that create a formula field “testfield “ name in custom object with text type with following formula.
fieldB__r.Fieldc__c


Now create a custom button in custom object with following
Content Source=URL


/apex/pagename?id= testfield__c

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

This was selected as the best answer
kevindotcarkevindotcar

 

Just to add to Navatar's solution, I would change the URL definition to
   ../apex/pagename?id= testfield__c


The ".." will pass the server name;  and if you have a page controller, or if other things are going on (like a page redirect) it will make it easier to get the host name.

 

 

TradeServicesTradeServices

Would you mind assisting me in connecting 2 objects (Leads - Projects) with the convert button? I created two objects and I need one to convert into another. The code that I wrote is not working properly. Thank you in advance.