You need to sign in to do that
Don't have an account?
udayarangareddy mekala
TRIGGER UPDATE
Hi
I wrote the trigger whenever i will update the phone field on the ACCOUNT object,respective phone field on the CONTACT object updates automatically.i posted the code below but it was not updating the phone field on CONTACT object.
trigger updatephone on Account (before update) {
Map<id,account>accmap = new Map<id,account>();
for(Account acc:trigger.new){
accmap.put(acc.id,acc);
}
List<contact>listcon = [SELECT id, Phone, accountid FROM contact WHERE accountid in :accmap.keyset()];
for(Contact con :listcon){
con.Phone = accmap.get(con.accountid).Phone;
}
update listcon;
}
I wrote the trigger whenever i will update the phone field on the ACCOUNT object,respective phone field on the CONTACT object updates automatically.i posted the code below but it was not updating the phone field on CONTACT object.
trigger updatephone on Account (before update) {
Map<id,account>accmap = new Map<id,account>();
for(Account acc:trigger.new){
accmap.put(acc.id,acc);
}
List<contact>listcon = [SELECT id, Phone, accountid FROM contact WHERE accountid in :accmap.keyset()];
for(Contact con :listcon){
con.Phone = accmap.get(con.accountid).Phone;
}
update listcon;
}
Instead of Before Update we need to Use after Update, It will Work.
If this solves your Problem, Mark it as the Best Answer.
Thanks,
SFDC Beginner
You need to write a trigger on after update event. I just updated the code, try the below one,