You need to sign in to do that
Don't have an account?
How to unfollow the message from Chatter
when ever am inserting record am displaying the EntitySubscription to the record owner chatter. How to delete this added EntitySubscription from the user chatter.
If record CreatedDate > 90days i want to delete those EntitySubscription from the chatter.
Give me ideas on this. how to delete EntitySubscription from the chatter.
The following is the code am using to add "EntitySubscription" to the chatter.
trigger EntySubscription on Employee__c(after insert)
{
public List<AccountTeamMember> teammember;
if ( Trigger.isInsert)
{
for (Employee__cest: Trigger.new)
{
if ( est.Id != null)
{
Account ac = [select Id,Name from Account where Id =: est.Account__c];
teammember = [ select Id, UserID, AccountId from AccountTeamMember where AccountId =: ac.Id];
System.debug('****************Team members**************'+teammember);
if( teammember != null && teammember.size() > 0)
{
for(Integer i=0; i<teammember.size();i++)
{
System.debug('*********User ID*****'+teammember+'*******'+teammember[i].UserID);
User u = [SELECT Id,Name FROM User where Id =:teammember[i].UserId];
System.debug('************User Name***************'+u.Name);
EntitySubscription follow = new EntitySubscription (
parentId = est.Id,
subscriberid = teammember[i].UserId ) ; //your User Id
insert follow;
}
}
}
}
}
}
Hello Krish,
Checkout my comment in your previous post,and let me know in case of any iissues.
Regards,
Bharathi
Salesforce For All
Mrk this post as solved, if it helps you