Tag Archive for visual flow

Go With The Salesforce Flow – Issues With Record Access/Sharing & How To Fix!

Salesforce Flow Series

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.

Visual Flow Create AccountShare Record

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.

Visual Flow Error - An Unhandled Fault Has Occurred In This Flow

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.


Screen Element to Pause and Let Sharing Catch Up


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!

Go With The Salesforce Flow – The Basics

Salesforce Flow Series

Create A Simple Salesforce Flow – A Quick Guide

Let’s create a very simple Salesforce Flow.  This will be an “Interview” Flow which will require user interaction (because it contains screens for the user to interact with) that will be launched from an Opportunity button.  The Button URL will pass a Flow Variable (The Opportunity ID of the record we are on) so that when the Flow starts, it will know the Opportunity we are working with.  First, the Flow will pull some information from the Opportunity and store it in Flow Variables for later use.  Then compare the Opportunity Amount and determine whether it is a high dollar value Opportunity.  If it is a high dollar value Opp, it will give the user the option to create a Case that will alert a service team to assist with winning the Opp.  If the user decides to create a Case, it will automatically be associated with the proper Account.

Create A Basic Salesforce Flow

Locate the Cloud Flow Designer by navigating to Build –> Create –> Workflow & Approvals –> Flows or simply type “Flows” into the Quick Find box within Setup.

Salesforce Flow Menu

This page will list all of your existing Flows.  This is where you can manage each version (each Flow creates a new version each time you click “Save As”), and decide which to Activate.  Click the “New Flow” button.

Salesforce Flow Create New Flow

The top left side of the page is where you will find all of the elements you will use within your Flow.  In this Flow, we will be using Screens, Record Create, Record Lookup, and Decisions.  To add an element to the Flow, simply drag and drop the desired element onto the canvas.

Salesforce Flow Palette

The next tab contains Resources.  This is where you can create the variables, formulas, choices, etc. that will be used within the above steps/elements.  You can also create them while you are editing the above steps so I rarely use this tab personally.  It would be beneficial if you wanted to create all of your variables, choices, etc. in bulk first before you started building the Flow elements that used them.

Salesforce Flow Resources

First, let’s drag a Record Lookup Element onto the canvas.  The Record Lookup settings immediately open.  Name it, then you specify the filter criteria for locating the desired Opportunity.  In this case, we want to locate the Opportunity with the ID that we will pass in with the Button we create on the Opportunity record.  You will need to create a new variable for this data to be passed in from the Button.

Salesforce Flow Record Lookup

Because this variable needs to be accessed from outside the Flow (data passed in the button URL) make sure to set it to at least “Input” – and not “Private.”  “Input and Output” will work just fine too.

Salesforce Flow Variable

Now, select the fields from the particular record that you “Looked Up” that you would like to assign as a variable to reference within your flow.  In other words, assign the current value of that field to a Flow variable so that you can access it in the Flow.  In the example below, I’ve set the Opportunity Name & Amount to Flow variables.  Be sure to set the correct variable type – Number, Text, Currency, etc.

Salesforce Flow Assign Variables

After save, the canvas will be revealed again.  Every Flow must have a “Start Element.”  In other words, after you have many steps added to a particular Flow, you must indicate where the Flow should begin.  Hover over and click the green arrow to set this step as the Start Element.

Salesforce Flow Start Element

Now drag over a Decision step.  This is where you can add logical operators to impact the course of the Flow.  In this basic example, we are going to evaluate the Opportunity Amount and have two outcomes, Low & High.

Salesforce Flow Decision

Now drag a Screen element onto the canvas and give it a name.  A Screen is used to present and collect information from the user.  This screen will be used if the Opportunity has a High Amount as determined by our Decision Element we just created.  First give it a name:

Salesforce Flow Screen

Then, within the “Add a Field” tab we can drag over a “Display Text” Field.  Here we can reference variables to dynamically control the content.  Then, drag over a “Radio Button” Field and give it a name, and create two choices.

Salesforce Flow Radio Buttons

Here is an example of creating a new Choice:

Salesforce Flow Choice

Save this Screen and create another for the final Screen all users will be taken to upon completion of the Flow.

Now you can start piecing together the Flow and its order of operations.  First, connect the “Record Lookup” to your “Decision” element by clicking and dragging from one element to the other.  Then, connect from the Decision to the Finish Screen.  Because you are connecting from a Decision and there are multiple outcomes, a popup will appear and let you choose which outcome should follow the desired path.  In this case, we only want to take the user to the Finish Screen if the Opp Amount was Low, otherwise we want to take the user to our “High Dollar Opp” screen where we let them decide if they want to create a Case.

Connect from the Decision to the Finish Screen for “Low” Opps and from the Decision to the High Dollar Opp Screen for “High” Opps.

Salesforce Flow Decision Routing

Now drag another Decision Element to the canvas.  This time it will be used to evaluate the user’s input on the High Dollar Opp Screen, whether the user selected “Yes” or “No” to create a Case.

Salesforce Flow Decision

The last step is to drag a “Record Create” element onto the canvas.  If the user selects to create a Case, this is the step which will fulfill that choice.  Select the Object you would like to create a record of and indicate how to populate specific fields.  Here I’ve set a custom Subject, passed in the same AccountID as the Opp (stored in a variable) and selected an existing Picklist Value for Priority.

Salesforce Flow Record Create

Now the Flow should look something like this.  We lookup the Opportunity from which the button was clicked (the button URL will pass into the flow the Opportunity ID) and assign Flow variables to the current values of specific fields.  The Flow evaluates the Opportunity Amount and determines whether it is High or Low.  If Low, the user is taken directly to the Finish Screen.  If High, the user is taken to the High Dollar Opp screen where they are able to select whether to create a Case.  If they decide not to create a Case, they are taken to the Finish Screen.  If they select to create a Case, the case is created using a Record Create element.

Salesforce Flow Path

It’s best practice to create a Screen to display any errors that may occur within the Flow.  By default, any errors which may occur within the Flow (for example, a validation error upon a record create or update) will display a generic Flow Fault message that will not help us diagnose what went wrong.  By creating a Screen for errors, we can see exactly what went wrong and take steps to prevent it.  Drag another Screen element and then add a “Display Text” field.  For the text to display, use the “Resource” dropdown and select the $Flow FaultMessage.

Salesforce Flow Error Screen

Now, be sure that you’ve connected the “Create A Case” Record Create step to your Finish Screen.

Next, connect the Record Lookup and Record Create steps to the Error Screen.  Since those steps already have a next step path indicated, the Flow editor knows that this path will be utilized for any faults that occur within the Flow.  This is indicated by the word “Fault” in the connection to the Error Screen.

Salesforce Flow Path

Now, make sure you have saved your Flow and click the Close button.  You will be taken back to the Flow Detail page within the Salesforce Setup menu.  Take note of the Flow URL indicated on this page.  Click the “Activate” link next to the Flow version (if you have saved multiple versions using the “Save As” button) you would like to use.

Salesforce Flow Activate Flow

Now we are almost done!  Time to create a new button that will be placed on the Opportunity Page Layout.  Navigate to the Buttons, Links, and Actions page for Opportunities and click “New Button or Link.”

Salesforce Flow New Button

Name your button, select “Detail Page Button” and “Display in existing window without sidebar or header” and “URL.”  Now we will specify the URL that the user will be redirected by pressing the button.  This button should take users to the Flow and pass in the Opportunity ID.  Use the Flow URL that was listed on the Flow Detail page, and then type a “?” question mark.  Then, carefully type the name of the Opportunity ID variable we created in the Flow.  Next, add an “=” equals sign and then you can use the dropdown to select a merge field for the Opportunity ID.

Salesforce Flow New Button

Now save the button and add it to the desired Opportunity Page Layout.

Salesforce Flow Press Opportunity Button

Because I pressed the button on an Opportunity greater than $10K I am given the option to create a Case.

Salesforce Flow Opportunity Flow Screen

If I choose “Yes” – the Flow creates a Case for the same Account as the Opportunity as specified in the Flow.  Now when I open the Account, I see the associated Case.

Salesforce Flow Account Case

We Did It!

Give yourself a pat on the back!  You should be proud of yourself for following along!  This is a very simple example that only scratches the surface of the power of Flow.  I hope you find it helpful if you have never worked with Salesforce Flow before.  This simple example contains all of the basic building blocks that you can use to grow your Flow skills!  We will continue the series focusing on some less covered topics such as:

  • How to default an existing picklist value within a Flow (to its current value).
  • Set the finish location of a Flow embedded within a Visualforce page.
  • How to work with multi-select picklists within a Flow, retain current values and append or add new ones.
  • Workaround for a Flow interview that creates a new record that the running user only has access to based on sharing rules and the sharing rules haven’t taken affect yet!
  • How to share specific records automatically using an autolaunched Flow without sharing rules!


Go With The Salesforce Flow – A Salesforce Visual Flow Series

Salesforce Flow Series

Go With The (Salesforce) Flow

The Salesforce Cloud Flow Designer AKA Salesforce Flow is a powerful tool that allows you to build complex logic without writing any code.  It is the premier declarative development tool within the Force.com Platform.  It enables you to leverage Variables, Constants, Formulas and logical processes like Decisions, Lookups, and more to interact and update the data within your Salesforce Org.

Two Primary Types of Flows

Autolaunched Flow: This flow does not require any user interaction and can be launched automatically such as from a process or Apex.

Interview: This flow requires user interaction.  The flow can take different paths depending on the information the user inputs as they navigate through a series of screens.  This flow can run from a URL directly, be added as a button to any record page (run as a pop-up), or embedded within a Visualforce page.

What Can You Do With A Salesforce Flow?

A Salesforce Flow can accomplish a combination of anything a user could do manually with anything a workflow rule could do, and more!  Need to clone an account and duplicate all of its associated contacts, opportunities & contracts and automatically associate them with the new account? You can do that!  Want to guide a user through a series of screens in order to gather all the necessary information for a contract AND based on this info and data contained within the Account, Opportunity, and existing Contracts decide whether the new request can fall under an existing contract or a new contract is needed?  Once that decision has been made, it can automatically create the new records!  What if you need to manually share an Account & Opportunity (Read/Write) within a private sharing model, specifically to whichever user is input into a custom lookup field (Opp –> User)?  You can do this with an autolaunched flow!

Need to create a button on an Opportunity that will automatically close the Opp as Won, create a new Contract record with information from the Account & Opportunity, AND create a Case assigned to a specific service queue that will fulfill the sale?  An Interview Flow allows this!

Get Ready!

As you can probably already tell, Flows are a powerful thing.  We’ll spend some time getting you up and running if you’ve never worked with Salesforce Flow before.  Then we’ll really focus on some less covered topics such as:

We’re going to have lots of fun.  If there is anything in particular that you would like to cover, I would love to hear about it in the comments!