Record Sharing Using Salesforce Flow | Create Custom Record Sharing Logic Using Salesforce Flow

In Salesforce, we can share the records with the different user who has access to that particular record, and when we share the records, the ownership also gets changed to the shared user.

In this Salesforce tutorial, we will learn about sharing records in Salesforce with a flow. We will also learn what sharing records means and when we can use them.

Additionally, we will see how to create sharing records in Salesforce Flow with a scenario and explanation.

Sharing Record In Salesforce Flow

What is meant by sharing records in Salesforce?

In Salesforce, there are three types of sharing records:

  • Owner-Based Sharing: In this type, we can share records owned by the specific user and determine the access level.
  • Criteria-Based Sharing: In this sharing, we can set the conditions as criteria, and when the records meet that criteria, they will be shared with another user.
  • Manual Sharing: We can share records manually in public groups, roles, and individual users. While sharing the records manually we can give Read-only or Read/Write access to whom we want to share.

Scenario to Create Custom Logic for Record Sharing in Salesforce Flow:

While working as a Salesforce Admin for a US-based Organization that provides software solutions, I was assigned the task of sharing Case records with the Salesforce Queue. The company currently operates in California, Florida, and Georgia.

Here, the Case raised from any of these regions will be assigned to the queue specifically created to handle the cases of that region. There are the following prerequisites to creating auto-launched flow in Salesforce:

  • We need a Custom Picklist Field “Region” on the Standard Case Object with the following values: California, Florida, and Georgia.
  • Then, we need Three different Queues to assign cases with the following names: California Queue, Florida Queue, and Georgia Queue.
See also  Various Ways to Use Classic Email Templates in Salesforce Flow

How to Create a Flow in Salesforce to Share Records

Using the above scenario and the following steps, we will see how to create a flow in Salesforce to share records.

1. Log in to Salesforce Org. -> Click on the Setup. -> Home Tab. -> In Quick Find Box, Search for Flows. You will see an option under Process Automation. -> Click on Flows.

Sharing Records Using Salesforce Flow

2. Click on the New Flow button to create a new flow.

Sharing Records Using a Salesforce Flow

3. We want to create a flow for creating the records, so we have to select the Record-Trigger flow. Then, click on the Create button.

You can read the whole article on Record-Triggered Flow in Salesforce.

Sharing record by Salesforce Flow

4. Here, in the Object field, we need to select which object we want to create flow. In our scenario, we need to create flow on the Case Object. In the Configure Trigger option, we need to select when we want to invoke this flow.

Sharing Records Using Salesforce Classic Flow

5. In our scenario, when we select the Case Region value, the Case raised from any of these regions will be assigned to the queue specifically created to handle that region’s cases.

So, we have to select Fast Field Update, which is used when we want to execute flow before the record is saved to the database.

Sharing Records Using Salesforce Lightning Flow

6. First, we need to get queue details in the flow. For that, we have the Get Records element; as we click on that element, we need to enter the following details.

  • Label: This label will display on the canvas where the Get Records element is. Here, I have entered the Get Queue Details displayed on the Get Records element.
  • API Name: It will automatically populate as we click the text box.
  • Description: Description is optional; we can enter a short intro about our flow.
  • Object: Here, we need to select from which object we will fetch the records; in this field, we have to select the Queue object, but in Salesforce, the behind-the-scene queue is also part of the Group, so we have to select the Group object.
Share records using the salesforce flow

7. Now, to assign a record, we have DeveloperName from the group object to relate with the Region from the Case Object. That means whenever we select a region from the case object, it will find a queue by using DeveloperName.

Share records using the salesforce flow in Lightning

8. Now, we have to assign a case owner to the queue according to the value that we will select in the region.

Sharing Records Using a Salesforce Flow example

9.  After setting up all labels and conditions, click the Save button to save the flow. For that we need to enter the Flow Label; here, I have entered the Share Records using Salesforce Flow. The API Name will automatically populate as we click the text box. The Description is optional; we can enter a short intro about our flow.

See also  How to Delete a Flow in Salesforce

Then click on the Save button.

Sharing Records Using a Salesforce Flow in Lightning

10. It is best practice in the flow to always Debug the flow before activating it, and then, if no error occurs, Activate the flow.

Now, we will see step-by-step what we have done in the flow and its flow direction.

  • Step 1: Here, we have to define on which object we have to create a flow.
  • Step 2: Then we fetch Queue Object records from the queue that we have created already.
  • Step 3: Then, we have to assign the queue as the owner according to the region.
Sharing records from flow in Salesforce Classic

11. To check whether the flow is working properly, go to the object on which you have created a flow. If you have selected trigger flow when the record is created, then create the record.

As per our scenario, the company currently operates in California, Florida, and Georgia. A case raised from any of these regions will be assigned to the queue specifically created to handle that region’s cases.

Sharing records from flow in Salesforce Lightning

12. On the Details Page, you can see that the Case Owner has changed to vale and queue according to the Region field.

Sharing records from flow in Salesforce

This is how we can Share a record using the Salesforce Flow.

Conclusion

I hope you have an idea about sharing records in Salesforce with a flow. We have seen what sharing records means, their types, and when we can use them. Additionally, we have also seen how to create sharing records in Salesforce Flow with a scenario and explanation.

You may like to read: