You need to sign in to do that
Don't have an account?
Aswini
How to write a trigger to update each contact's phone using Account's phone if contact's Mailing country is equal to Account's Billing Country.
How to write a trigger to update each contact's phone using Account's phone if contact's Mailing country is equal to Account's Billing Country.
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
All Answers
Try Below Trigger Please Mark It As Best Answer If It Helps
Thank You!
I got a small error in the above code could you plz help me to solve that.
Try Below Code Error Has Been Removed Please Mark It As Best Answer If It Helps
Thank You!
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Trybelow trigger,
trigger updatephonebasedonaddress1 on Account (after update) {
List<contact>conlist=new List<contact>();
set<Id>accid=new set<id>();
for(Account a:trigger.new){
accid.add(a.id);
}
List<Account>acclist=[select id,name,phone,BillingCountry,(select id,Phone,LastName,MailingCountry from contacts)from Account where id=:accid];
for(Account a:acclist){
for(contact c:a.contacts){
if(c.MailingCountry==a.BillingCountry){
c.phone=a.phone;
conlist.add(c);
}
}
update conlist;
}
}