Getting Started with Process Builder – Part 20 (Add Chatter Followers to Record)

A few months back, I had written an articleAdd/Remove follower to record with Visual Workflowto discuss a way through which we can addor removeChatter followers to account record. As you all know Flow runs in user mode, it means the Flow we had developed will only work for System administrators or users with theModify All Userspermission. There are few business scenarios where business wants some workaround so that Flow will work for all the users (Only for users who have editaccess on Account). First of all, I want to say thanks to Adam Plockifor asking such a great question on Success Community. Let’s start with a business use case

Business Use case

Warren Mason is working as System administrator at Universal Containers (UC). He has received a requirement to develop an application, that will allow users (For those, who have edit access on account object) to add Chatter followers to record.

Solution for the above business requirement

There are few solutions possible for the above business scenario. We will use Flow and Process Builder (because it runs in system mode) to solve the above business requirement. The advantage of using Flow with Process builder is, you don’t have to assign Force.com Flow Userfeature license to the users. Before proceeding ahead, you have to understand EntitySubscriptionobject in Salesforce. 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.

Field Name

Details

ParentId

ID of the record or user which the user is following

SubscriberId

ID of the User who is following the record or user

Follow the below instructions to create a Flow and Process Builder to solve the above business requirement

1. First of all create a Custom FieldAdd Follower (Data Type: – Lookup (User)) on theAccount object. We will use this field in the Flow and Process Builder.2. To create a Flow, click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows3. Click onNew Flow, it will open Flow canvas for you. Now we have to create two variables. First, create a Text variableAccountId to store the accountId (we will pass the account Id throughProcess Builder) as shown in the below screenshot

Second Variable FollowerID is used to store the user Id, whom you want to add as a Chatter follower to record.

Text Variables to store follower Id

4.To add a Chatter follower to record, drag-and-drop aRecord Create ( Give the nameAuto add follower to record) onto the window and map the fields according to below details

6. Save your flow with nameAdd Chatter follower to record PBand close the canvas. Don’t forget to Activatethe Flow.

Launch a Flow from Process Builder

Our next task is to create a Process on the Account object to launch a Flow. To create a workflow on theAccount object follow the below instructions

1. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder and click on the New button, Enter Name, API Name and then click on the Save button

Define Process Properties

2. The next step is to add entry criteria. For this click on Add Object, select Accountobject and for the entry criteria, Select when a record is created or edited, as shown in the below screenshot, once you are done click on the Save button

Evaluation Criteria

3.The next task is to add ProcessCriteria, To do this click on Add Criteria, enter Name, Type of action and set filter conditions (In this case set [Account].Add_Follower__c Is Changed True) and click on theSave button, as shown in the following screenshot

Process Criteria

4. The next step is to addan Immediate action to Process. Click onAdd Action(Under Immediate actions), Select the type of action to create (In our case Flows), and then fill out the fields to define the action, as shown in the following screenshot

Add action – Flows

5. Once you are done, click on theSave button, it will redirect you to Process canvas. Finally, theProcess will look like the following screenshot

Don’t forget to active the Process by clicking on theActivatebutton.

It’s time to test this App

1) Now LoggedIn through a business user account. In this demo, I am going to use Demo User account (Profile assigned: – Standard User, Force.com Flow Userfeature license is not assigned to this user ).

Demo account

2) The next step is to edit the record and populate the Add Follower field as shown in the following screenshot

Final result

Finally, checkout the Follower section available on the record detail page.

Note: – I will suggest you to implement this first on your developer org test it and then move it to Production.

Mario

Would it be possible to use a similar system to unfollow too? I used this way to auto-follow opportunities and it really works great. Now I was just wondering if I can also create the unfollower in the same way???