In Salesforce Classic, you can manually control sharing on a per-Record basis for any object that doesn’t have Public Sharing Settings. You can then put a useful Sharing button on record pages. The different sharing permissions you’ve granted can then be managed:
This feature isn’t available yet for Lightning so we’ve built a Flow Action called Set Sharing Manually that does it. It demonstrates the use of Lightning Web Components to create screen components that do useful ‘member management’ Salesforce administration. The component is based on seminal work by Shane McLaughlin.
Watch the video above to see it in action.
About the Package
This action is packaged with a sample object called Sharing Test Object, that comes preinstalled with a Set Sharing button. Keep in mind that per-record sharing only works on objects that have their Organizational sharing set to either Private or Public Read Only. In other words, if everyone automatically has full Read/Write access to an object type, there’s no point in using per-record sharing. In many orgs, most or all object types have Read/Write access and don’t enable manual sharing. So this capability is somewhat specialized. Sharing Test Object comes preset to Public Read Only, so you can assign sharing manually. Feel free to delete Sharing Test Object and the demo flow that also comes in the package.
1) Install the package (or push the source to a scratch org).
(or push the source to a scratch org).
2) Go to Permission Sets and assign the Sharing Demo permission set to your current user. This will cause the Sharing Test Object to show up in your App Launcher.
3) Using App Launcher, create a sample Sharing Test Object record. Note the “Set Sharing” button that comes preinstalled on the Sharing Test Object page layout.
Trying It Out
Click on Sharing, and you’ll see two tabs you can use:
Select one of the types of entities and click Search to retrieve the full list of records. (SFDX-only note: scratch orgs show a bunch of sample Roles, but these Roles do not work with this action. Create your own orgs in a scratch org to try this feature out).
This component has the following attributes:
|addTabName||The label used for the ‘Add’ tab|
|editTabName||The label used for the ‘Edit’ tab|
|selectionRequired||Boolean. validates that at least one entity has been selected.|
|recordId||The Id of the record being acted upon.|
The UI that appears in the flow screen is made up of three Lightning Web Components, and the source can be found here. The LWC components are decoupled from the specific of Sharing, and there are other potential use cases for this UI. Think of it as a general Lookup for Users, Roles, Queues, Groups and other entities, and a list building tool to assemble a list of these entities. For example, we have a variant “in the lab” that manages Initial Submitters for Approval Processes and another that manages Approvers for Approval Process Steps.