set<id> oppid = new set<id>();
for(opportunity opp:trigger.new){
if(opp.StageName=='closed won')
oppid.add(opp.Id);
}
list<opportunity> opportunity=[select id, createdby.name from opportunity where id in:oppid];
for(user users : [select id from user ])
{
EntitySubscription[] followingES = [select id, parentid, subscriberid, parent.name from EntitySubscription where subscriberid = :users.id];
Map<string,string> following = new Map<string,string> ();
for( EntitySubscription Entitysub : followingES )
following.put( Entitysub.parentid, Entitysub.parent.name );
If(opportunity [0].createdby.name == 'xxxx'
{
EntitySubscription follow = new EntitySubscription (parentId <>:opportunity [0].id,subscriberid = users.id);
delete follow;
}
}
}
4 件の回答
Hi,
From blog post - Auto Remove Followers From Closed Opportunity
Have you tried on this an app from app exchange - Chatter Unfollow Rules - Managed (https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003IX0UEAW)