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

Populating a custom field

Hi All,
I have a requirement which is almost the same as a standard functionality in SFDC.In the Contact object page,while creating a new contact,on choosing an Account,it is seen that the Mailing street and mailing City fields are automatically populated without the user typing it.
I have the same requirement but on a different object.
Can anyone help me to find the solution?
Thanks in advance,
It sounds like you should be able to solve this using Apex pretty easily. There is currently a thread on the Apex Code Development discussion board that may help you out:

Also, check out the Apex Guide here:

And the Visualforce/Apex Wiki:

VN -

Also, you should consider whether you really want to copy the data over to the new object.  This approach will work fine if you want to use those values as defaults - which means a one-time synchronization.

But if you want the new object to always have the current value of mailing street and city from Contacts, you should use a relationship to point back to the original data.  Consider the case where the mailing street changes for the Contact - do you want those changes to be in the new object's record?  What about if the user had changed those values in the new object record?

Duplicating data frequently seems like a good idea, but you should make sure it addresses issues like these.

Hope this helps.


Hi Ricky,

Thanks for the reply.

I have written an Scontrol which queries the Account table and fetches the value to autopopulate the custom field.But currently my Scontrol is triggered on click of a button on the Contact page.(ie:On clicking the button,the Scontrol is invoked which opens up Edit mode for the contact,and prepopulate the custom field.)

But i want this to happen when the account information is filled.(ie:When the user enters value for the Account,my Scontrol should get triggered,exactly as the standard functionality in SFDC).