Salesforce Flows - Dynamically share a case record by populating a field on the case

Salesforce flows are impeccable in effectively addressing a business use case.Today we will try to address the below business use case using salesforce flow.

Business Use Case

As part of the service cloud audit programme, the Head of Customer Service has dedicated a team of Service Managers who will be assigned to a case to view the details of the case and question the case owner, if required.

The dedicated service managers will be able to view/edit the case only when they are assigned to the case.The case owner will not be changed and the service manager will not be added as part of the case team.

Solution Design

Following are the considerations that will drive the solution design:

  1. Organisation Wide Defaults(OWD)- The OWD is set to Private which means that only the case owner and the users above on the role hierarchy will be able to access the record.

  2. Case Teams- We can’t use the case teams as it is clearly stated in the use case.

  3. Role Hierarchy/Public Groups/Sharing Rules- We can’t add a new role and add the users to it as that would enable the users to access all the cases owned by users under the hierarchy. Creating public groups and assigning the users manually might be overwhelming to the admins and high on maintenance.Automating the same will incur lots of unnecessary overhead.

  4. Creating a look-up field to user on case and add a case share record whenever a user is added to the field. Moreover, we can grant Field Level Restrictions to the field which will drive more flexibility and robustness to the solution.

Looking into the above scenarios, we can opt for the fourth option of creating a look-up on case object as the possible solution.

Let's jump into the details.

Step 1: We will create a lookup field on Case to User object. We will call it as Case Audit Manager.

Step 2: We will create a new permission set to ensure that access level granularity is properly granted. (Not covered in this post)

Step 3: We will create a process builder and a flow. The process builder will fire whenever the Case Audit Manager is populated. The process builder will call the flow which will in turn add the user into the CaseShare table.

Implementation

Field Configuration: Create a field called Case Audit Manager(CaseManager__c) which will lookup to the user object.

Field Configuration

Field Configuration

Process Builder Setup

Created a process builder called CaseShare Flow which will be called only when the above field is updated.Immediate Action is being the flow.

Screenshot 2021-04-04 at 01.04.51.png
Process Builder Setup

Process Builder Setup

Flow Design

This will be a very simple flow where we will insert a record into the CaseShare table.

Overall Flow Structure

Overall Flow Structure

Screenshot 2021-04-04 at 01.13.35.png
Flow Element Details

Flow Element Details

The above post could be extended to multiple use cases. Hope you enjoyed this post. Please let me know in the comment section how you leveraged the above to solve your use-case.