+ Start a Discussion
Chris BenenatiChris Benenati 

Accessing Custom Settings from within Custom Button definition

I defined a Custom Settings table with API name IDs__c  to hold the field and record type identifiers I need when doing URL hacks to prepopulate new objects.  I used a List type for the IDs__c and "Managed" it to create a record containing all of the definitions.

Then I try to create a custom button that references one of these settings.  An example of a reference I try to use is:

If such a reference appears within the definition and I click "Check Syntax", I get told "There was an error communicating with the server."  If I try to save the definition, I get told "An internal server error has occurred".

It doesn't matter if I use a simple URL definition (Behavior = Display in Existing Window) or JavaScript  (Behavior = Execute JavaScript).  I can even use the reference only within a string constant or in a JavaScript comment, and I get the same results.

Does anybody understand this?
Best Answer chosen by Chris Benenati
Chris BenenatiChris Benenati
It started working.  I have no idea why.

All Answers

Hi, seems like  you would need to query the custom settings table to get the values, are you doing that as well ? 
Chris BenenatiChris Benenati
No.  I am using the Salesforce GUI, not an Apex class.  If, for example, I do not use JavaScript, I am just entering an URL, which can interpolate the value of merge fields.  The reference to the Custom Setting is just another merge field, isn't it?

Example -- here is the definition of a functioning custom button:

& CF00N1500000FV1HX={!Household__c.Id}
& Name="This field will auto-fill on save"
& retURL=/{!Household__c.Id}

I just want to replace the the identifier "CF00N1500000FV1HX"  with something like "{!$Setup.IDs__c.CON_Household_Name__c}" so I can change the definitions of all the identifiers in one place (the custom settings) when I re-deploy.  Shouldn't that be do-able?

BTW, I have eliminated the server errors by changing my custom settings from a List type to a Hierarchy type (don't know what that made a difference).  But I still can't get the references to work correctly.
Chris BenenatiChris Benenati
It started working.  I have no idea why.
This was selected as the best answer