-
Is there any need of map when we can insert & update using List only in contact mailing address?
trigger update_MailingAddress on Contact(before insert,before update) { set<id> accountIdset=new set<id>(); for(Contact con:trigger.new){ if(con.AccountId!=null){ accountIdset.add(con.AccountId); } } list<account> accList = [select id,billingCity,billingState,billingStreet,billingCountry from Account where id iN : accountIdset]; for(Account acc : accList){ for(contact con :trigger.new) { con.MailingCity = acc.billingCity; con.MailingState = acc.billingState; con.MailingStreet = acc.billingStreet; con.MailingCountry = acc.billingCountry; } } }-
This discussion was modified 6 years, 2 months ago by
Deepak.
-
This discussion was modified 6 years, 2 months ago by
Log In to reply.