WeDid: Salesforce Automating Record Sharing Based On Dynamic User Field Value

Posted in

Challenges

Case sharing rules are set to private. The customer would like to share it with specific users based on a User Lookup field.

 

Solutions:

Create a trigger that automatically adds the User into CaseShare (Manual Sharing Rules). The solution must also cover the following scenarios:

  1. When the User Lookup field is changed from Fred to John, make sure that you will add John and remove Fred.
  2. If the User Lookup field is the same user as the Case Owner, don’t add him/her into CaseShare. You will get an error.
  3. If the User Lookup field is pointing to an Inactive User, don’t add him/her into CaseShare. You will get an error.

 

Related Objects Case Objects
Components Apex Trigger
Complexity Medium

Get in touch today to see how WDCi can help your business.