function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

prepopulation of lookup field

Hi All,


can anyone tell me how to prepopulate an account lookup field while creating a new record from a related object. And this should happen through onclick javascript of a button cos i m nt using VF pages here.






Please find attached an example where account id needs to be prepopulated from object1 on to object2 when object2's instance is edited. We are using URL to prepopulate certain fields here:-

1) Account ID

2) Job Number
I am presuming you want to pass Account information from "Object1" to "Object2".

As you are talking about using button to implement this hence, I think simple URL to update this information in the survey object. I think the attached code will explain things in a better way:-

I am also assuming that "Object2 "object is linked by a lookup field with the "Object1" object


Here id is the id of the Object2 object
00N80000004I201- is the id of the html control storing Accountid
00N80000004I206- is the id of the html control storing JobNumber


This is an example with edit you can do something similar with create too.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.


Paul BourdeauxPaul Bourdeaux

Does anybody know how the HTML control Id is generated?  I don't like the idea of having to screen scrape to get them - doesn't make for a very portable App...