Add Sharing In Salesforce Visual Flow
Have you ever needed to create or edit a record within visual flow but the running user of the flow did not have access to that record? In orgs with Private or Public Read Only Sharing models, you need to grant the proper access to the running user of the flow.
Grant Access to Flow Running User w/ AccountShare Record
You can pass in the User ID of the flow’s running user as an input variable upon the start of the flow. Then, you will need to create the proper sharing permissions for that user and the appropriate record. Example below for the AccountShare record. Here I’ve just hard-coded a User ID as and example. For a full production solution, you will want to pass in the ID of the flow’s running user. You can do this in the Button URL or using process builder for an auto-launched flow. Check Go With The Salesforce Flow – The Basics for step-by-step on creating this button and passing in variables as URL parameters.
This can also be accomplished using a custom User Lookup Field on an object and process builder. For example, the process could run anytime this custom field is modified, start an auto-launched flow that adds the user in that field to an AccountShare record.
The Problem – Delay In Providing Access
I’ve seen circumstances where the org is large enough and sharing settings complex enough that even though the flow’s running user should have the appropriate access to update the record that has just been created (even though they aren’t the owner), it errors out because it can take a moment before the sharing is active.
In these cases, I’ve just had to simply add a Screen Element step to pause a beat, let the sharing settings take effect, and then let the user continue the flow and update the record.
Have you ever encounter this? What is your experience using flow to automatically share record access? Comment below or tweet @SFDC_r – I would love to hear from you!