Trigger Contacttrigger on Contact(after update){
set<String> setcon=new set<String>();
for(Contact c:Trigger.new){
setcon.add(c.Email);
}
List<Account> acclist=[select Id,Name,Email__c,(select Id,Name,Email from Contacts) from Account where Email__c in:setcon];
Map<id,Account> mapacc=new Map<id,Account>();
for(Account acc:accList){
mapacc.put(acc.Id,acc);
System.debug(mapacc);
System.debug('Record data is'+mapacc);
if(mapacc.containsKey(acc.Id)){
acc.Email__c='default@gmail.com';
}
}
update accList;
}
Comments
Post a Comment