Posts

Showing posts from August, 2018

When the Opportunity is deleted then delete accounts and contacts of that opportunity

Trigger DeleteTrigger on Opportunity(after delete){         Map<Id,Opportunity> setopp=new Map<Id,Opportunity>();         for(Opportunity opp:Trigger.old){          setopp.put(opp.AccountId,opp);                           }         List<Account> deletelist=new List<Account>();         List<Account> accountlist=[select Id,Name  from Account where Id in:setopp.keyset()];         for(Account acc:accountlist){             deletelist.add(acc);                     }                   if(!deletelist.isEmpty() && deletelist.size()>0){                     delete  deleteli...