+ Start a Discussion
Prashant GulvePrashant Gulve 

Write a trigger on Contact object (after update) of any filed on contact the Mailing address filed should get change to Pune .

Write a trigger on Contact object (after update) of any filed on contact the Mailing City  filed should get change to Pune .
e.g- if i made changes to any contact filed the Mailing City filed should get update to Pune.
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Prashant,

Why do you want to got to After Update. You should be using Before Update context . What is meant by any field update? Do you mean by any field on Contact or any field on Contact Address?

Thanks,
Prashant GulvePrashant Gulve
Hi Praveen,
I have task that i have to work on after update of contact object any filed get updated then the Mailing City should get change to pune. so basically when we Update any Contact Object Fields then the Mailing City should get change to Pune it's like this. on this i have to write a trigger.

Thank you
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Prashant,

Can you check if this trigger solves your requirement.
 
trigger ContactCityUpdate on Contact (before update) {
    for(Contact c:Trigger.new){
        Contact oldContact= Trigger.oldmap.get(c.id);   
        if(c!=oldcontact)
        {
            c.MailingCity='Pune';
        }
        
    }
}

If this solution helps, Plese mark it as best answer.

Thanks,
 
Prashant GulvePrashant Gulve
Thank you Praveen for your help, but this code not working. also we have to write code on after update without using if condtion.