Can I use apex trigger and the Chatter API to auto - subscribe sales team members to opportunity.

Also, Please explain a scenario if you have worked on any.

2 Answers 2


Just insert a EntitySubscription record for each sales rep.

[EntitySubscription] represents a subscription for a user following a record or another user. A user can subscribe to a record or to another user. Changes to the record and updates from the users are displayed in the Chatter feed on the user's home page, which is a useful way to stay up-to-date with other users and with changes made to records in Salesforce. Feeds are available in API version 18.0 and later.

Therefore you should create a new after insert trigger. The trigger has to populate the field parentID with the opportunity Id and the subscriber Id with the user Id.


You can also use the Chatter API (classes in the ConnectApi namespace) in the trigger:

ChatterUsers.ConnectApi.Subscription subscriptionToRecord = ConnectApi.ChatterUsers.follow(Network.getNetworkId(), 'me', '006D000000CtwLa');


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .