Adding a Manual Sharing Button to Records with Lightning Flow

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.

Installation

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).

Configuration

This component has the following attributes:

addTabNameThe label used for the ‘Add’ tab
editTabNameThe label used for the ‘Edit’ tab
selectionRequiredBoolean. validates that at least one entity has been selected.
recordIdThe Id of the record being acted upon.

Developer Notes

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.

7 replies
    • Maximilien Huet
      Maximilien Huet says:

      Hello Mahendra,
      I don’t know if you can see my previous post so I post it here :

      Regarding the problem of installing the package : “The ActionId specified was invalid for ActionType QuickAction”. It is due to some action present in the Sharing Test Object Layout.
      I downloaded the sources and edited this layout in order to correct this error.

      I have uploaded a package from my dev org for you guys having the same problem as me and that don’t whant to manipulate Salesforce CLI (I have tested to import it on another dev org and it worked) :

      https://login.salesforce.com/packaging/installPackage.apexp?p0=04t3X0000022yrq

      Hope this helps.
      Thanks again for this amazing package Alex 😉

      Reply
  1. Maximilie
    Maximilie says:

    Great solution!
    Regarding the problem of installing the package : “The ActionId specified was invalid for ActionType QuickAction”. It is due to some action present in the Sharing Test Object Layout.
    I downloaded the sources and edited this layout in order to correct this error.

    I have uploaded a package from my dev org for you guys having the same problem as me and that don’t whant to manipulate Salesforce CLI (I have tested to import it on another dev org and it worked) :

    https://login.salesforce.com/packaging/installPackage.apexp?p0=04t3X0000022yrq

    Hope this helps.
    Thanks again for this amazing package Alex 😉

    Reply
  2. John Visser
    John Visser says:

    LIke Michael and Mahendra, I am facing the problem that it cannot be installed in a sandbox first and we never test new things in a production org.
    Is there a solution for this?

    Reply
  3. Michael
    Michael says:

    May I know is this “plug-in” not available to install in the sandbox area? I try to do so but error message display as below:

    ==============================================

    This app can’t be installed.
    There are problems that prevent this package from being installed.

    (Sharing_Test_Object_c-Sharing Test Object Layout) The ActionId specified was invalid for ActionType QuickAction.

    ==============================================

    Or is there any pre-requisite setting I have to do before?

    Thanks.

    Reply

Trackbacks & Pingbacks

  1. […] Adding a Manual Sharing Button to Records with Lightning Flow […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply