Hello folks,
Let’s dive in to get elements this week. Get elements, a.k.a. SOQL queries, get one or more values from the Salesforce database. These values can be used later in our flow.
Before we go deeper into the get element, we need to talk about variables. Variables are containers in Salesforce that keep values for us temporarily until we use them. This is kind of like writing something on a napkin rather than in the address book. To save values permanently, we write them to the database; in other words, we write them in a record and save/commit to call and use them later. On the other hand, variables are available only in the flow we are in, and they vanish after we complete our flow interview.
In Salesforce flows, we create variables on the left panel in the resource manager, and some others are automatically created for us.
When we get a complete record, for example, Salesforce creates a record variable automatically and saves all the values of the get element in this variable.
Let’s assume we find only one opportunity record match in our get step labeled as “Get Account”. Salesforce auto-creates a get element record variable with all the field values that are available under that record. As flow makers, we can refer to one or more field values in that variable when we are building our flows – in this case {!Get_Account.Id} – for the recordId.
What are the parameters we need to set to execute a successful get step?
Typical scenario: We would like to find all Accounts with the name ACME.
Setup: Tell your get step you want to get a record of Account object type.
Set the filter condition as Account Name equals ACME.
What are the possible outcomes here? We may find:
- No records
- One record
- More than one records
Let’s look at these possibilities:
No records: Your get step won’t fail. However, you will get a record variable automatically created with the value null assigned to it.
One record: You will have one record in your record variable complete with its recordId, name, and all other field values. You can use these later in your flow.
More than one record: You have options here. First, you can tell the get element whether you need to sort these records according to one field value. Then you can decide whether to get and assign the first record to a record variable or assign all the records to a collection variable (this means N number of containers of the same type). All these are auto-created for you.
One important tip here is to catch the “No records” outcome. If you don’t do that and use the record variable later in your flow, you will receive an error message, and your flow will fail.

So insert a decision step right after your get element and check whether {!Get_Account} is null true. If that is the case, stop all operations and exit the flow gracefully. In screen flows, you can insert a screen element to show the user a message explaining what happened.
Use the filter criteria wisely because if your get element returns more than 50K records, you will hit the governor limit, and your flow will fail.
This wraps up everything I wanted to write about the get element this week:
Recently published content: How do you extend upsell/crosssell offers using a screen flow on a Lightning page. Click here to this Salesforce San Francisco User Group Video on the Salesforce Break Youtube Channel to learn.
Do you need to see advanced use case flow applications for inspiration? Click here to watch the short video on a Loan Application Use Case.
Enjoy
P.S. Originally published on 11/22/2021.
Read the previous issue of the newsletter here.
Subscribe to the weekly educational Salesforce Flow Tips newsletter here.