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!


2 comments for “Go With The Salesforce Flow – The Basics

Leave a Reply

Your email address will not be published. Required fields are marked *