Tag Archive for 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 – Using Multi-Select Picklists

Salesforce Flow Series

Using Multi-Select Picklists Within A Flow

Have you ever tried using multi-select picklists within a Salesforce Flow?  Did you update the picklist field with a new value and instead of adding the new value it replaced the existing value(s)?

I’ve found this to be a very unintuitive aspect of Salesforce Visual Flow.  If you do it wrong, you update the multi-select picklist field with new values, but wipe out the already existing values.  I have good news, however, because today I will show you a workaround!

Adding, Not Replacing, A Multi-Select Picklist Value In Flow

First store the existing picklist values as a multi-select picklist variable in your Record Lookup step.

Multi-Select Picklist Flow - Store Variable

Ensure the variable is set to “Picklist (Multi-Select)” data type.

Multi-Select Picklist Flow - Variable Type

Use a “Multi-Select Picklist” field within a Screen Element for users to interact with.

Multi-Select Picklist Flow - Choice Field

Create a new choice to be used as the default and set it to the variable that was set in the Record Lookup step.

Multi-Select Picklist Flow - Create Default Choice

Now create a new choice for every option you would like to provide your user.

Multi-Select Picklist Flow - Create Desired Choices

After you are done creating the necessary choices, ensure you set the correct one as the default choice as shown on the “Screen” image above.

Now create a Record Update step to update the desired multi-select picklist field from the value in the screen field.

Multi-Select Picklist Flow - Update Record From Multi-Select Field


That’s it!  But, what if you want to update using a different type of Screen Element field?  Check out below to see how you would update with a boolean field.

Create a boolean field.

Multi-Select Picklist Flow - Boolean Field to Update Multi-Select Picklist


Then, after creating a Decision step to determine whether the user has checked the box, create an Assignment step.  The Flow will utilize this step only if the box is checked.  Here, I’ve used another variable to store the record’s current picklist values.  Ensure that you use the “Add” operator and that you add a semicolon before the picklist value.

Multi-Select Picklist Flow - Assignment Add And SemiColon

Now add a Record Update step to update the picklist value with the variable’s value.

Multi-Select Picklist Flow - Update Field From Variable


Now we’re ready to run through the entire process!  Check out the Opportunity below.  The Multi-Select picklist field “Topics” currently has the values: Purchasing & Accessories.

Multi-Select Picklist Flow - Opp With Two Values Selected

Our Screen Element properly displays those as the two chosen fields, and gives use two available choices: Warranty & Service.

Multi-Select Picklist Flow - Add Two Values

I’ve gone ahead and added both of them and click “Next” in the flow.

Multi-Select Picklist Flow - Add Two Values

The Record Update takes place, and if I refresh the Opportunity, I now see the additional values were added to the two already existing values.  It didn’t wipe out what was already there…perfect!

Multi-Select Picklist Flow - Refresh Opp Values Added

Now, in my Flow I reach the boolean checkbox.  I check and click “Next.”

Multi-Select Picklist Flow - Use Boolean for Repair

Now when I refresh my Opportunity and click into the Topics field I see the following in the box and just below it.  All 5 values have been selected within the field and only “Replacement” has not been selected.

Multi-Select Picklist Flow - Opp Adds Repair


There you have it, we were able to successfully update a multi-select picklist within a Flow using two different methods & fields (one requiring an assignment step).  We successfully updated the values without removing or replacing the existing values.  Way to go!

Check out the rest of the Go With The Salesforce Flow Series for more Visual Flow tips & tricks!


Go With The Salesforce Flow – How to Default the Current Picklist Value

Salesforce Flow Series

Salesforce Flow – How to Default An Existing or the Current Picklist Value

Have you ever wanted to use a dropdown list within a Salesforce Flow Interview Screen and have it dynamically populate with the current value of that picklist field?  Well I’m here to show you how!

First, make sure you store the current value of the picklist field in a variable within a Lookup step in your flow.  Here, I’m storing/assigning the current Delivery/Installation Status value to a variable.

Salesforce Flow Record Lookup

Then, on the desired screen where you would like to present this information, add a “Dropdown List” field.

Salesforce Flow Add Dropdown List

Now, you will want to give your users a choice between all of the available values of that picklist field.  Hint: using this method to add a choice future-proofs your flow so that even when available picklist values are changed your flow won’t need to be updated!  Within the choice settings section, select “Picklist Choice.”

Salesforce Flow Add Picklist Choice

Now you will choose the Object & Field where you would like to pull the available choices from.  Notice the spelling mistake “Piclist Choice Settings” – c’mon Salesforce!

Salesforce Flow Add Picklist Choice

Now let’s quickly recap what we’ve accomplished so far.  We’ve taken the current value of a picklist field and stored it within a Flow Variable.  We’ve also added a Dropdown List field to an Interview Screen and populated it so that our user can choose from all of the available picklist values from the same field.  If we stopped here, we would be storing the current value in a variable, but the Dropdown List on the Interview Screen wouldn’t automatically default to the current value.  The user could choose from any available value for that field but would not have any way of knowing what the current value on the record is.  See, I can’t set the Default Value!

Salesforce Flow No Default Option

The key to selecting a default value is to create another choice, this time just a standard “Choice.”

Salesforce Flow Create Default Choice

Now this is where it gets fun.  Instead of typing a static Label for this default choice, we are going to use the variable we stored so that it will always dynamically display the text of the current value.  We also want the variable’s value to be the “Stored” value of this selection so that if we update the record from this Screen Choice Field the correct information will be passed.

Salesforce Flow Create Default Choice

Now we are able to set the Default Value of our Dropdown List to this new default choice.

Salesforce Flow Screen Picklist Field

Here it is in action!  We have an Opportunity that has a current Delivery/Installation Status value of “In progress.”  If we interact with this Opportunity via our Flow, we would expect to see this value already populated.

Salesforce Opportunity

Sure enough, “In progress” is the selected value within our Dropdown List field!

Salesforce Flow Defaults to Existing Value

One important note: this method will actually create two choices that are exactly the same.  We created a choice that contains the full list of all available values for this picklist field, and then we also have the default/current value.  As you can see below, you see “In progress” twice.  It doesn’t matter which one you select, this field would pass the same value!

Salesforce Picklist Duplicated


Stay tuned as our Salesforce Flow Series continues with more tips & tricks!

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!