PartOfTheOhana
PartOfTheOhana

Reputation: 685

How to prepopulate a standard lookup field in a standard object?

Setup:

On my Event Object, I want to prepopuate the 'assigned to' field with a different user name 'Babe Ruth' than the current owner. This field is a Lookup field. The field name is Owner, if that makes a difference. We're implementing this by modifying the url with S-Controls that are calling Apex.

Problem:

  1. I'm not sure how to get the field name for the field. I've inspected the element, and it says to be evt_1. Is there a way to verify that is the absolute field name, and not a relative one?

  2. I can't get the page to save with my changes. In the URL hacking I add: evt_1=Babe%20Ruth&saveURL=..., which successfully displays the changes, but when I click save, the field is not saved with 'Babe Ruth', but my name as Owner!

I have looked at this reference and others and am still stuck.

http://raydehler.com/cloud/clod/salesforce-url-hacking-to-prepopulate-fields-on-a-standard-page-layout.html

Upvotes: 1

Views: 8023

Answers (3)

thatherahere
thatherahere

Reputation: 111

You can try this solution, here I'm getting field id dynamically instead of hardcoding it any where.

http://customforce.wordpress.com/2014/05/06/getting-field-id-dynamically-to-pre-populate-fields-value-for-new-record/

Upvotes: 0

brovasi
brovasi

Reputation: 167

For standard object, you can use Firebug to target an element in your edit page and take the id of the component. You should find something like "cas4_", "cas3_", ... which represent the standard field id ==> for example cas4 is for Account lookup in Case object I think. URL paramaters : cas4=Hello+World&cas4_lkid=001000000dgst4

Upvotes: 1

Acuariano
Acuariano

Reputation: 498

If you look in the link you send, it says:

The best way that I've found to get the ID of the field that you want populated is by navigating to the field in setup. For example, if I want to prepopulate ObjectDetail_c.TextField_c, I would go to Setup => Create => Objects => ObjectDetail => TextField, which takes me to to the URL

Once you know the id of the field you want to populate, you use <fieldId>=TextValue&_lkid=<recordId>. Using the example in the link, if the fieldId is CF00NA0000005JzZX, then the parameters are

CF00NA0000005JzZX=Babe+Ruth&CF00NA0000005JzZX_lkid=<userId>

Where < userId> is the id of the Babe Ruth's user record.

Upvotes: 3

Related Questions