Posts

Showing posts from June, 2018

Child to parent updation in salesforce

Trigger ContactTrigger on Contact (after update){ Map<Id,Contact> mapcon=new Map<Id,Contact>(); List<Account> acclist=new List<Account>(); for(Contact con:Trigger.new){ mapcon.put(con.AccountId,con); } acclist=[select Id,Name,Email__c,(select Id,AccountId,Name,Email from Contacts) from Account where Id in:mapcon.keyset()]; if(acclist.size()>0){ for(Account a:acclist){ a.Email__c=mapcon.get(a.id).Email; } update acclist; } }