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
nikkeynikkey 

how can i Copy address fields from corresponding account record to contact while saving.

Hi folks , 

Can any one help me on this requirement .

how can i Copy  address fields from corresponding account record to contact while saving.


Thanks in Advance .
Satish_SFDCSatish_SFDC
Do you want to save the Address fields 'while saving the contact' or while 'saving the Account'.

In the first case, you can use a simple formula field to dynamically refer to the Account fields.
In the second case, you have to note that there may be multiple contacts for a single account. So you have to write a trigger which will loop through all the contacts of the account and then save them with the new address.

Regards,
Satish Kumar
Swapnil PatneSwapnil Patne
Hi Nikkey,

If you are creating a single contact then simply create it from that account by clicking "New Contact" button and it will copy over address details automatically by default.

If you are creating/ inserting mutiple contacts i.e. via data loader then you may need to create a custom formula field Text (Account.BillingStreet & Account.BillingCity & Account.BillingCountry) which will copy/ get address details from account on all contacts whenever a contact is created. Try it out in SB. 

BR 
Swapnil
Swapnil PatneSwapnil Patne
Hi Nikkey,

If you are creating a single contact then simply create it from that account by clicking "New Contact" button and it will copy over address details automatically by default.

If you are creating/ inserting mutiple contacts i.e. via data loader then you may need to create a custom formula field Text (Account.BillingStreet & Account.BillingCity & Account.BillingCountry etc...) which will copy/ get address details from account on all contacts whenever a contact is created. Try it out in SB. 

BR 
Swapnil
nikkeynikkey
Hi Sathish and Swapnil ,

Thanks for ur reply ,

The Requirements is : 

Create a page which will have some fields from contact object.
Along with those fields add a custom dependant pick list, using Apex and Visualforce, on form.
(Don’t create new fields on contact object.)
Provide a 'Save' button. When user clicks on save button, create contact record and navigate user to new page having saved contact’s fields as read only.
Copy Business address fields from corresponding account record to contact while saving.


Note: a) Use First Name, Last Name, Email, Phone, Account Name fields from contact.
(also add Account look up )
b) Add any values in pick lists.
c) Use Picklist 1, Picklist 2 fields to store pick list values.
d) Use trigger to copy address functionality.

I shall appreciate ur help .