Populate Custom Lookup Fields from an S-Control
Written by ShamrockCRM on April 4, 2009 – 12:00 pm -Probably the most common request I receive from clients is to automatically populate a new record with fields. This is a simple process, usually involving an S-Control and some URL parameters. It gets a little more complicated, however, when you start wanting to populate lookup fields on the new records.
Warning: This isn’t documented or supported by Salesforce, and could change at any time.
First, you need the ID of the field in question. If you’ve already created S-Controls to populate new fields, this probably isn’t new to you. However, if you haven’t, the easiest way is to navigate to the field in question in Setup. (Create > Objects > Object Name > Field Name, for custom objects). Then, take the ID from the URL of the custom field, for example:
http://ssl.salesforce.com/00N50000001xxxx
You’ll want to pass this as a URL parameter when creating your new object, with “CF” preceding the ID and “_lkid” appended. You’ll also want to provide a value for the textbox, as the ID isn’t enough. So you’ll want to pass something like this for a Contact:
?CF00N50000001xxxx_lkid=00N50000001yyyy&CF00N50000001xxxx=John%20Doe
Basically, it just comes down to knowing to append “_lkid” to the ID of the field you’re passing in with the Salesforce ID, as well as providing a value to display in the textbox on the creation screen. Hopefully this helps you out!
Related posts:

By Dan Waldron on Apr 4, 2009 | Reply
I finally decided to write a comment on your blog. I just wanted to say good job. I really enjoy reading your posts.
By Jeff on Jun 1, 2009 | Reply
What do the xxxx and yyyy refer to?
Thanks!
By Hans on Jun 4, 2009 | Reply
Thanks – just what I was looking for. Do you have a good way to pass the recordtype as well?