ow can i create trigger on contact object where if change mailing address field or enter new mailing address in new contact then it automatically add same mailing address on (Ohter Address Field)
You simply need to create a before insert and before update trigger on Contact object that will copy the value from mailing address to other address fields as per your requirement. Sample code is given below:
trigger updateAddress on Contact(before insert, before update) {
for(Contact con : trigger.new) {
con.other_Address_Field__c = con.Mailing_Address_Field__c;
}
}
//Please replace the other_Address_Field__c with the API name of the address field in whch you need to copy the mailing address and also replace the Mailing_Address_Field__c with API name of Mailing Address field
Please let me know if you need any further help or information on this.
You simply need to create a before insert and before update trigger on Contact object that will copy the value from mailing address to other address fields as per your requirement. Sample code is given below: Please let me know if you need any further help or information on this.
Thanks,
Abhishek Bansal.
Try this code.
if you found this answer helpful then please mark it as best answer so it can help others.
Thanks
Akshay
Try this hoe it will help you.
trigger UpdateAddress on Contact (after insert, after update)
{
for (Contact c : Trigger.new)
{
if(c.MailingAddress!=null)
{
c.OtherAddress = c.MailingAddress;
c.MailingCity = c.MailingAddress;
c.MailingState = c.MailingAddress;
c.MailingPostalCode = c.MailingAddress;
c.MailingCountry = c.MailingAddress;
update c;
}
}
}
Thanks,
Ajay Dubedi