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
PBS_IC786PBS_IC786 

Auto fill fields in edit page

How can I auto fill fields based on a lookup field in my custom object edit page?  Basically,  after I select an Account for my custom object, I want the account address and contact info filled into the other fields of my custom object.  How can this be done easily?
 
All help is greatly appreciated...
michaelforcemichaelforce

I had an answer for you right up until your last word..."easily". :smileytongue:

There is a way that I have implemented to do something similar, and it involves creating a 'spoof' page of the edit screen and overriding the 'new' and 'edit' buttons to send the user to my page instead of the standard one.  If you don't know, or know someone who knows, how to swing javascript then I'm afraid I don't have an answer for you.

PBS_IC786PBS_IC786
so I can't just create a link which runs an scontrol and have the fields populated on that page based on the user clicking that link?  I know it seems kind of "dirty" but is it possible to do that without making the process generate a new page...
Greg HGreg H
Just a thought but you could place an inline scontrol in the custom object edit page.  The sControl could be the account selection piece you are referring to in your question.  Anyway, upon selection of an account you could have the sControl reload the custom object edit page with the varibales for the fields you want to populate in the URL.  The edit screen would be able to populate the passed variables into the fields.
-greg
michaelforcemichaelforce

PBS,

Good point... you could definitely add an s-control which, when clicked, would populate certain fields after making a call to the account table.  I thought you were looking for an automatic operation 'on save' or 'on selection of account'.

Your s-control would then use the AJAX toolkit to lookup query the account (if one is chosen) for the required fields.  Then place those values in the form using the document object (e.g. document.formname.fieldname = results[0].value).

Hope this helps.

Jack SenechalJack Senechal
So how do you add an inline sControl that shows up on the edit page? My sControls so far only show up on the detail pages...
michaelforcemichaelforce
Right, it would have to be on the detail page.  Upon being invoked, the s-control would make the updates and then simply refresh the page so the new values are displayed.
PBS_IC786PBS_IC786
I think I understand what you are saying Greg but what is the format of passing in values through the URL for the specific fields which I want to update? How do I know what their ids are? Anyone have any samples of what a URL of this type looks like...

Thanks for all your help...
michaelforcemichaelforce
The "add me as a salesforce.com contact" link in my signature is a good example.  To find the names of the fields I just went to the form and chose to 'view source'.  Then you have to comb through the HTML and find the field names you want.
AndrewPhilAndrewPhil
I think I want to do something like this to auto-fill fields on a page, but I would really love to see a sample of a completed piece of code, as my coding skills are...subpar