Written by Jonathan Davis
On August 1, 2022

Salesforce Flow Basics Pt. 1: Data Elements, Decision, and Assignment

Jonathan_SalesforceFlowBasics

About the Author:

Jonathan Davis is a Salesforce Consultant at Venn Technology in Grapevine, TX. He enjoys the challenge of mastering all things Salesforce. With seven certifications under his belt and counting, he’s always tackling Salesforce Trailhead to up his integration and configuration skills.

 

The goal of this four-part series is to provide foundational knowledge on how to use Flows in Salesforce. Flows are a powerful tool for automating processes in Salesforce and are something that every Salesforce Administrator or Consultant should be familiar with.

At a high level, a flow involves a few basic concepts:

  • Elements - The pieces used to build the flow. Each type of element performs a different function. 
  • Resources - These are created and exist inside a specific flow (as opposed to records that exist in the database) to perform logic and store values when the flow runs.
  • Trigger - The event that tells the flow to begin and usually provides the flow with some starting information, such as a Salesforce record. 
  • Logic - The flow uses logic that you configure in the flow to decide what to do within the flow.
  • Result - The flow does one or more actions, such as creating or updating a record in Salesforce, displaying information to a user, sending an email to a customer, or some combination of those actions, and then ends.

Salesforce Flows are declarative, which means they do not require writing code to set them up. This makes them readily accessible to Administrators and Consultants who have not learned how to write code. Salesforce continuously adds features to Flow Builder, so it can do many things that were once impossible without code. 

Flows are built with a series of elements connected to one another. When a flow is triggered to run, it works its way through the elements one at a time and performs different logic and actions based on which element is used and the way it is configured. 

In this series, we will discuss all of the elements available to work with in the Flow Builder.

 

Jump to a section:

Data Elements (Create, Update, Get, and Delete)
Assignment Element
Decision Element
Tips and Tricks

 

Data Elements (Create, Update, Get, and Delete)

In Flow Builder, there are three groups of elements: Interaction, Logic, and Data

The Data Elements reach out from the flow instance and interact with Salesforce data, allowing the flow to retrieve information from or make changes to records in the database. 

 

Create Records

The Create Records element allows you to create new records in your Salesforce org’s database. It can be used to create one or multiple records. 

When creating one record, the simplest way is to select “Use separate resources, and literal values.” Choose the type of object you want to create a record for, and assign the field values you want the new record to have. 

Once the record is created this way, you also can reference the newly created Record ID in other flow elements. 

In this example, we created a new Account Record for Venn Technology:

Create New Account Record

You can also reference a record variable or collection of records used previously in the flow and create a new record using the values that were set previously. This is the only way to create multiple records with one Create Records element.

 

Update Records

The Update Records element is very similar to the Create Records element, except that it makes changes to existing records instead of creating new ones. 

It is also similar to the Get Records element in that you are able to filter for the records you want to update when you use the “Use separate resources, and literal values” option. When filtering records this way, be aware that the Update element will revise all records in the database that meet the criteria, so it’s a good idea to be as specific as possible with your filters.

Alternatively, you can select “Use the IDs and all fields from a record or record collection” to update a record that was previously stored in the flow, such as one from a Get Records element. In this case, to make changes to the values on that record, you should have done so previously in the flow using the Assignment element.

Venn Technology Senior Salesforce Consultant

In this example, we use the Update Records element to update the MailingState field of all contacts in the system that have an AccountID field value of “0014T000008zal9QAA.” If we only wanted to update a single contact, we would need to add more filters, such as the Contact ID, or FirstName and LastName fields.

Update Account Records

 

Get Records

The Get Records element is used to “get” one or more records from the database based on filter criteria set in the component. Getting a record stores its values within the flow, as well as the values of records it looks up to (such as a Contact record looking up to an Account record in its AccountID field), allowing you to reference it in other flow elements and resources. 

The filter criteria is based on values found on the specific record you’re getting, such as the ID or name of an account. Multiple criteria can be used, and the condition requirements can be set using “and,” “or,” or custom logic. When getting your criteria, the filter logic should be as specific as possible (such as an ID value), so that you only get the records you want to work with. 

Get Records can be set to retrieve either the first record that meets the criteria, or all of the records that meet the criteria. Multiple records are stored together in a collection.

In the example below, this Get Record is retrieving the first account with a value of “Venn Technology” in the Name field and storing it for use in the flow.

Get Records Element

 

Delete Records

The Delete Records element is used to delete records from the database. Similar to the Update Records element, you can either delete records stored in variables defined earlier in the flow, or specify the object and filter criteria needed to find the records you wish to delete. Similar to the Update Records element, the Delete Records element will delete all records that meet the filter criteria—make sure to be specific.

In this example, we use the Delete Records element to delete an account with the Id of “0014T000008zal9QAA.” By using the Id field in the filter, we ensure that only this specific account record is deleted.

Delete Records Element

 

Assignment Element

The Assignment element is one of the Logic elements, which means that it does not directly affect the contents of the Salesforce database. Instead, it is used to interact with records and resources within the flow by changing, adding, or subtracting the values of variables and fields. This is very useful for setting or changing record values before creating or updating them, and for using variables to perform logical functions.

Below, we use the Assignment element to change the StageName field of an opportunity to Closed Won and set the CloseDate field to today’s date with {!$Flow.CurrentDate}. This does not update the Account field in the database yet, but does set the values in preparation for the Data elements.

Assignment Set Variable Values

 

Decision Element

The Decision element is one of the most important elements in the Flow Builder, as it allows for the creation of multiple paths based on various criteria, allowing a single flow to output different results based on decision criteria.

When creating a Decision element, set the name and criteria for one or more outcomes. If the criteria is met in the flow, then the flow will follow the path for that outcome. If none of the criteria for the created outcomes are met, the “Default Outcome” is followed.

In this example, we create a Decision element that checks if the Opportunity record’s StageName field value is Closed Won.

Edit Decision - Opportunity Closed Won

If the Opportunity is Closed Won, the flow follows the “Yes, Opportunity is Closed Won” path to Create Contract. If the Opportunity is not Closed Won, the flow follows the Default Outcome and sends an email to the sales representative.

Decision Element - Is Opportunity Closed Won?

 

Tips and Tricks

Now that you know how to use the Data, Assignment, and Decision elements, here are some tips and tricks when using them.

New call-to-action

 

Using a Decision after a Get Element

The Get Records element will not error out if it does not find anything with the filter criteria provided, but if later elements in the flow attempt to reference the record when there is not one, those elements may cause an error. 

For this reason, unless you can ensure that your Get Records elements will find a record, it is a good idea to create a Decision element after your Get Records element to see if it found anything. Do this by checking if the variable from the Get Records element is not null, as shown below.

Here, we check to see if any Opportunity Products were found in the previous Get Records element:Get Records - Opportunity Products

If the variable is null then the record was not found—the default path is followed and the flow ends. If records are found, the flow continues. 

In this example, the flow checks for Opportunity Products, updates them if the flow finds any, and if none are found, the flow ends:

Blog1 - 9

There may also be times when the requirements of your automation may change depending on if there is an existing record or not and, in those cases, you may want to check if the record is present. If the record is not present, check to see if there is an existing contract for an account. Update the contract if there is one and, if there isn’t, choose “Create Contract” instead.

Update/Create Contract

 

Using Decision results later in the flow

The outcome of a Decision element is stored in the flow as a boolean (true/false) value that can be referenced later on in the flow by other decisions or formula resources. 

This can be useful in various situations where a decision was made previously in the flow that you want to reference later.

Below you can see:

• The first decision checks the size of the account
• The second decision determines if a new contract is needed
• The third decision checks if a new contract was just created for a large account, thereby sending an email to a Sales Representative if it was

Decision Outcome Details

Decision Element in Flows Builder

 

For more information on Salesforce Flows, check out our next blog post: Flow Element Basics Pt. 2 – Variables, Collections, and Formulas.

 

 
 
Sign up for Venn Sync Newsletter