Using Flow to Auto Follow Records

Using Flow to Auto Follow Records

In Salesforce, users have the option to follow or unfollow records by simply clicking the Follow button on the record's page. Additionally, there's a feature that enables automatic following of records you create. To activate this, go to My Feeds in your settings and mark "Automatically follow records I create". If you wish to automate the follow/unfollow process, you can also use custom solutions. Here's a guide on using flow to auto follow records.

How to Use Flow to Follow Records

When a user follows a record, Salesforce stores this information in an object called EntitySubscription. This object has 3 important fields.
ParentId: Id of the record that the user follows
SubscriberId: Id of the user
CreatedDate: Date/time that the user started following the record

To automatically follow records, you just need to create EntitySubscription records using Flow. Similarly, to unfollow records, you can achieve this by deleting the corresponding EntitySubscription record.

Let's see an example.

Using Record-Triggered Flow to Auto Follow Case Records

In this example, let's build a record-triggered flow to make the account executive follow high priority cases related to the account.

1- Create a record-triggered flow that runs whenever a Case is created or updated. Specify entry conditions for the flow. For instance, this flow runs when Case's priority becomes High and there is an account executive. It works on record creation too (as long as it meets the criteria).

Start Criteria

2- Before making the user follow the record, you should check if they are already following it. Therefore, add a Get Records element to find the existing EntitySubscription record.

Get Entity Subscription Record

3- If there is no EntitySubscription record, we want to create one. Therefore, add a Decision element to check if it exists.

Decision Element to Check If It Exists

4- If it doesn't exist, create a new EntitySubscription record using a Create Records element. This is how you can auto follow records.

Create Entity Subscription Record to Auto Follow Records

At the end, your flow should look like this.

End of the Flow

Improvements

There are a few points to improve in this flow.

You can follow a maximum combined total of 500 people, topics, and records. If the user is already following 500 records, this flow will fail. Therefore, you may want to handle this situation in multiple ways.

Firstly, you can add a Get Records element to find all the records that the user is following. If the user is already following 500 records, do not create a new EntitySubscription record. On the other hand, you should consider automating the unfollow process as well. For instance, you can build another record-triggered flow that runs when the Case status becomes Closed and deletes the EntitySubscription records.

Here is the improved version of the same flow. It gets all the EntitySubscription records of the user and it filters the collection by the Id of the current Case record. Then there is an Assignment element to assign the record counts and finally a Decision element to check if the user can follow the record.

Improved Version of the Flow

Collection Filter element:

Collection Filter Element

Assignment Element:

Assignment Element

Decision Element:

Decision Element

Read this post to learn how to create a followed records list.

Be the first to comment

Leave a Reply

Your email address will not be published.


*