Auto Remove Followers From Closed Opportunity

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/SubscriberSalesforce does not have any inbuilt functionality like to create few rule for auto Follow or Unfollow records. OnChatter  a user can follow maximum a of 500 Peoples, topics, and records. To effectively manage Chatter, an organization has to use some App to auto unfollow records.
Business Use case :- Higher management in Universal Container wants to develop an app, so when an Opportunity is updated with Closed-Won/Closed-Lost all followers will automatically remove.
Solution of above business requirement
I think this is a good use case to start with 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 aboutEntitySubscription Object. It’s Represents a subscription for a user following a record or another user. User can subscribe to a record or to another user.
Field NameDetails
ParentIdID of the record or user which the user is following
SubscriberIdID of the User who is following the record or user
To develop this application follow the below instructions
  • Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
  • Click on New Flow, it will open flow canvas for you
  • First create a variable with name OppID and we will use into the flow, From Workflow we will pass the Opportunity ID into this variable
  • Drag and drop a Fast Lookup( Give the name Find all Followers ID) on the window
    • Select Object EntitySubscription
    • Enter criteria ParentId{!OppID.Id}
    • Save ID in Sobject Collection variable in my case it’s {!OppSubcribersID},same like below screenshot



To Get all EntitySubscription ID for Closed Opp
To Get all EntitySubscription ID for Closed Opp

  • Based on the Sobject Collection {!OppSubcribersID} we will decide Visual Workflow next action.  Now add one Decision element to decide whether closed opportunity has any follower or not based on that it will perform the necessary action. If  Sobject Collection variable {!OppSubcribersID} not equal to null it means record have some followers. You can take help from below screenshot to create Decisionelement



Decide What to do Next Remove follower or do nothing
Decide What to do Next Remove follower or do nothing

  • The next task is to delete all followers from opportunity record. To do that Drag and drop a Fast Delete( Give the name Remove Subscribers) onto the window, and select Sobject Collection variable{!OppSubcribersID}, as shown in the below screenshot



Delete Follower Records
Delete Follower Records

  • You have to add some action for default Decision action what happen If an Opportunity doesn’t have any followers. I used Assignment Logic because if an Opportunity doesn’t have any followers I don’t want to perform any action. You can take help from below screenshot



For Decision action Do Nothing
For Decision action Do Nothing

  • Finally our flow will look like the below screenshot
Auto Remove Followers From Closed Opportunity
  • Save the flow with name (Remove Followers From Closed Opp)  and close the canvas.
Create Workflow rule to fire our Flow
Our next task is to create a workflow on the Opportunity object on 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 Criteriaselect is StageClosed Won,Closed Lost, as shown in the below screenshot



Workflow Rule on Opportunity Won or Lost
Workflow Rule on Opportunity Won or Lost

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



New Flow Trigger Action
New Flow Trigger Action

5) Save the workflow and activate it.
It’s time to test this feature
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



Open Opportunity with some followers
Open Opportunity with some followers

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



Opportunity after Closed Won
Opportunity after Closed Won

Note:- If you want to increase this limit log a support case with Salesforce.com.
Labels:

Post a Comment

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget