Prepopulating fields using URL hacking – Part 2: Prepopulating custom fields

URL Hacking Series
Prepopulating fields using URL hacking – Part 1: The Basics
Prepopulating fields using URL hacking – Part 2: Prepopulating custom fields
Prepopulating fields using URL hacking – Part 3: Handling Special Characters
Prepopulating fields using URL hacking – Part 4: Passing in the Record Type
Prepopulating fields using URL hacking – Part 5: Multi-Select picklists

In the last post, we examined the basic concepts of how URL hacking works in Salesforce. In this post, we will see how to pass values for custom fields through the URL.

To start with, I have created a custom field called “MyCustomField” on the Account object. We want to pre-populate a value in that field from the URL.
Look at the following URL, where I am passing a value to a custom field on the Account object (the IDs in your SF instance may be different) :-

https://na9.salesforce.com/001E000000KC75x/e?retURL=%2F001E000000KC75x&00NE0000003cBZE=TestValueFromURL

image

To again break down this URL :-

001E000000KC75x This is the ID of the Account
/e?retURL=%2F001E000000KC75x the /e specifies that we are going to the edit page for the contact. The retURL=%2F001E000000KC75x  - this gives the URL to return to when the user clicks button.
&00NE0000003cBZE=TestValueFromURL This is the argument that passes in the value to the custom field. “00NE0000003cBZE” is the ID of the textbox for the custom field.

In order to derive this URL, I used the same technique as specified in Part 1 of this series. Basically, you get the ID of the field you want to populate by examining the HTML of the page. Then, you pass in a value for this ID in the URL. In my case, I right-clicked on the “MyCustomField” texbox and said “Inspect Element with Firebug”, and got the ID from there.

image

So there you go, you can now pre-populate values from your URL for your custom fields as well.

1 comment:

  1. What about passing values into Standard Salesforce.com fields like lead source or lead rating?

    /00Q/e?CF00NJ0000000gXw8={!Sales_Referral__c.Name}&CF00NJ0000000gXw8_lkid={!Sales_Referral__c.Id}&retURL=%2F{!Sales_Referral__c.Id}&Lea5.value="TSC"

    ReplyDelete