Pre Populate Forms in Salesforce using URL Hacking

Here’s an example of using URL hacking to pre-populate fields in a form on Salesforce.  The following can be set as a button action, or href on a page link that will pass parameters for whatever field I specify.

This example is from a button on Opportunity that opens a Case with the Account and the Opportunity automatically entered into the correct fields.

top.window.location =”/500/e?” +
“&retURL=” + “{!Opportunity.Id}” +
“&cas4=” + “{!Opportunity.Account}” +
“&cas4_lkid=” + “{!Opportunity.AccountId}” +
“&CF00N00000008acXt=” + “{!Opportunity.Name}” +

retURL tells Salesforce where to go if the user clicks the “Cancel” button on the form page

cas4 is the standard field id for the Account field on Cases, I pass the sObject lookup from the Opportunity to the Case (to get this, you can do a right-click, inspect element on the input field you want to populate, then use the Id of that field as a URL parameter).

cas4_lkid is a little trick that’s needed for the form to save correctly.  It stands for “lookupid” and it’s what Salesforce uses to tag the form entry with the related object.  If you do not add this, Salesforce will either throw an error or potentially save with the wrong related record.  THIS IS MOST IMPORTANT ON USER LOOKUP FIELDS.  If you don’t add this second field with the ID of the record you’re referencing for the user, when you save it will automatically throw your name in the field instead of the person you’re really trying to add.

CF00N00000008acXt is the field Id of a custom field that links an Opportunity to a Case

RecordTypeId is the record type of the case you want to create

As you can see, you can use this basic approach to take a user to any form you like and have the data filled in (to an extent) for them automatically.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s