In Salesforce a user can follow Chatter groups or Records. The chatter group manager can add/remove peoples to the group, for this Salesforce provides out-of-the-box functionality. To manage record Follower/Subscriber Salesforce does not have any inbuilt functionality like to create few rule for auto Follow or Unfollow records. On Chatter, a user can follow a maximum of 500 Peoples, topics, and records. To effectively manage Chatter, an organization has to use some App to auto-unfollow records.
Higher management at Universal Container wants to develop an app, so when an Opportunity is updated with Closed-Won/Closed-Lost all followers will automatically remove.
I think this is a good use case to start with the Headless Flow. After Summer’14 release sObject variables, sObject collection variables, and loops in a flow will be generally available. To solve this requirement we will use Visual Workflow, Workflow rule to fire Flow Trigger. Before going ahead with the solution you have to understand about EntitySubscription Object. It’s Represents a subscription for a user following a record or another user. A user can subscribe to a record or to another user.
|ParentId||ID of the record or user which the user is following|
|SubscriberId||ID of the User who is following the record or user|
To develop this application follow the below instructions
Our next task is to create a workflow on the Opportunity object on the creation and every time it’s edited event. To create a workflow on the Opportunity object follow the below instructions
1) Click on Name | Setup | App Setup | Create | Workflows & Approvals | New Rule
2) Select object Opportunity from the drop-down
3) Enter Name, for Evaluate the rule when a record is select created, and every time it’s edited, For Rule Criteria select is Stage= Closed Won,Closed Lost, as shown in the below screenshot
4) Add one Immediate Workflow Actions i.e. New Flow Trigger and Select Flow and set Variable (OppID) value as shown in the below screenshot
5) Save the workflow and activate it.
To test this application follow the below steps
1) Navigate to Opportunity which is not Closed and followed by a few users, like below screenshot
2) The next task is to update the stage to Closed-won, all followers are removed by Flow that we developed as shown in the below screenshot