WeDid: Salesforce Automating Record Sharing Based On Dynamic User Field Value
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:
- When the User Lookup field is changed from Fred to John, make sure that you will add John and remove Fred.
- 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.
- 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 |