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 deletelist;
}
}
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 deletelist;
}
}
nice post iam also write like this you check
ReplyDeleteyou can learn a Advantages of my Domain in Salesforce and how to use my domain in salesforce org step by step guid https://www.salesforcekeeda.com/2018/10/how-to-use-my-domain-in-salesforce-best.html
This is such a good idea,Great website. Keep up the good work!
ReplyDeleteLoadRunner Training in Chennai
Loadrunner course in Chennai
Loadrunner Training in Tambaram
Loadrunner Training in OMR
QTP Training in Chennai
Automation testing training in chennai
Best Loadrunner training institute in chennai
performance testing training in chennai