2

I've spent the last few hours looking at various articles and posts trying to find an answer with no luck. I'm trying to create a button using URL Hacking (I know some people frown on it with my skills it's the only way I can do it)

The Scenario:

I have a custom object called Training Form which I would like to add a button to the page layout to create a Case pre-filling the new Case with some of the fields for the Training Form. I've managed to get most of it working except for the following:

  1. I would like the Case.Account field to be populated with the related Account from the training form. I am aware of the need of a -lkid reference for the id as well as the account name but however I format the URL it does not fill in Case.Account.
  2. I'd also like to populate another lookup with a link back to the Training Form as well. Pretty much the same as 1.

Here's the url I have with parts I am struggling with highlighted in bold:

https://oursalesforceinstance.my.salesforce.com/500/e?
&RecordType=01224000000Eu2W
**&{!Case.Account}_lkid={!Trainer_Form__c.SiteId__c}
&{!Case.Account}={!Trainer_Form__c.Site__c}
&{!Case.Academy_Form__c}_lkid={!Case.Academy_FormId__c}
&{!Case.Academy_Form__c}={!Trainer_Form__c.Name}**
&cas14={!Trainer_Form__c.Name}
&cas5=Configuration&cas11=form
&cas15={!Trainer_Form__c.Configuration_Comments__c}

Where am I going wrong?

2

Using the merge fields for field names won't work. You have to inspect your page's source code to determine the correct values. Custom fields are usually named by their field ID, possibly prefixed by CF (for field types that need to be referenced in JavaScript, such as Lookup fields). For example, if I were doing this in my org, using a different field I have as a demonstration, I'd write:

/500/e?
&RecordType=01224000000Eu2W
&cas4_lkid={!Trainer_Form__c.SiteId__c}
&cas4={!URLENCODE(Trainer_Form__c.SiteId__r.Name)}
&CF00N50000001e65k_lkid={!Trainer_Form__c.Id}
&CF00N50000001e65k={!URLENCODE(Trainer_Form__c.Name)}
&cas14={!URLENCODE(Trainer_Form__c.Name)}
&cas5=Configuration
&cas11=form
&cas15={!URLENCODE(Trainer_Form__c.Configuration_Comments__c)}

Remember to use URLENCODE for any values which may contain punctuation, otherwise your URL may not work correctly for all values.

Note: I took a guess at some of the field merge values, which may be incorrect. Please check your API names.

  • Many thanks for your prompt response. I've had another go at it after your excellent advice and I've sorted it. However the URLENCODE statement rendered the pre-filled Case data in HTML so I had to remove them. I've tested with a few problem causing alphanumerics in a Training Form( ie: {}()/e?) and none of them seemed to cause a problem with the generation of the new Case with correctly rendered data. Many thanks for your help – Chris Apr 29 '17 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.