function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cmarz1cmarz1 

Custom List Button can't get data in URL

I have a custom object which has a related list of Accounts. I want a button that can create a new Opportunity for any account in the list.  So I created a custom list button that is a URL.  Using this guide I am able to get the field names I need into the URL: http://salesforce.phollaio.com/2007/04/02/how_to_obtain_a_field_id/

 

The problem is none of the Account data is showing up in the URL only data from the custom object.  Below is a sample of the URL list button in setup:

 

https://naX.salesforce.com/006/e?opp3={!CustomObj__c.Name}&opp4_lkid={!Account.Id}

 

This should give me a new opportunity with the Name equal to the name of the Custom Object and linked to the Account ID selected in the related list but all I get is a new opportunity with the name of the custom object.  The account isn't filled in.  If I manually type in the URL it works.  It appears I am not able to access any of the related list object's data via a List Button.  Is this really the case or am I doing something wrong?

jhurstjhurst

By using merge field in the manner described, the system can only pull data from the record you are accessing itself.  It has no way to run outside of the object to get the data you want.  This is one of the reasons that using URL hacks to build links is not really the best way to do what you want.

 

The supported method here is to use Visualforce and Apex code to do the data manipulation in the manner you want.

 

If this is not something that you can do, then you will be limited to the fields that exist on the record you are firing the list from.  In this case it looks like that is CustomObj__c.  If there is a link between CustomObj__c and Account, then you could do one of two things:

 

1. Use the {!CustomObj__c.Account__c} field (this assumes that the field on CustomObj is called Account__c).  This will pass the name of the Account to the field in question.  You would want to pass to opp4, not opp4_lkid.

 

2. If you need to pass the ID instead of the name, then you may have to create a new custom formula field on the CustomObj__c that just displays the Account ID.  You can then used this in the formula above.

 

Hope this helps.


Jay