7 Antworten
Hi Neeraja,As per my understanding your requirement is simply to unfollow an Opportunity record if ts stage is "Closed Won" for all the users who are following it.If i am right than please use the below code to acheive what you want :
Let me know if you need more help.Regards,Abhishek.trigger Autounfollowopp on Opportunity (after insert,after update) {
Set<Id> entityParentIds = new Set<Id>();
for(opportunity opp:trigger.new){
if(opp.StageName=='closed won'){
entityParentIds.add(opp.id);
}
}
delete [Select Id from EntitySubscription where ParentId IN : entityParentIds];
}