Flow: How To Use “Get Records”

This is the most complex data element, so we will break down each part to illustrate.

1. Sort Order
flow get records - sort order

There are three options – Not Sorted, Ascending, Descending. Ascending is from the smallest number to the biggest (if it is date, then it is the oldest to the latest) and Descending is the opposite. You would only want to sort them if later the order matters, for example you want to take the first X records sorted by date. Otherwise leave it unsorted to speed up the execution.

2. How Many Records to Store
flow get records - how many records to store

If you are only taking the first smallest number, or the one latest date, this will be an extremely helpful feature combining with the first feature. However if you want to take more than one, you will have to store all records and use other elements to handle this. (Ex. Loop, Decision, etc)

3. How to Store Record Data
flow get records - how to store record data

This is the most complicated setting, and there are four possible scenarios:

3 – 1. Automatically Store All Fields

The most straight forward option. After you choose this, a variable will be automatically created and you can reference all the fields later in the flow. If you only store the first record (Feature 2), it will be a record (single) variable; if you store all records, it will be a record collection variable.

3 – 2. Choose Fields and Let Salesforce Do the Rest

Similar to the first option, the system will also create the variable automatically for this option. The only difference is that you can choose specific fields to get.
Pros: The flow can run faster
The less fields you get, the less the system has to do. Thus, your flow can run faster.
Cons: Potential error might occur
If later you reference the fields that are not specified here, the flow will break.
(For example, I only got Date and Unit Price in graph 3-2.1. If I want to use the List Price to update another variable as graph 3-2.2, I will hit an error as graph 3-2.3.

3 – 3. Choose Fields and Assign Variables – When Get Only One Record

When choosing “Together in a record variable”, the outcome will be similar to choosing fields and letting Salesforce do the rest. However here you can assign a specific variable to store all the values.

flow get records - where to store field values

Alternatively you can store each field into a separate variable.

These two options in general will take more time for the system to run, and the use case is rare (Which is why there is (advanced) at the back). It might be that you have the variables set in another Apex script of flow, so you want to manually assign these values to unify the names across different places.

3 – 4. Choose Fields and Assign Variables – When Get All Record

Same as 3-3, here you need to assign a specific collection variable to store all the values.

ScenarioUse Case
Automatically Store All FieldsNeed most of the fields;
Want to prevent potential errors;
Flow is too small so tiny inefficiency can be omitted.
Choose Fields and Salesforce Do the RestOnly need 2-3 fields;
Flow is huge so performance is vital.
Choose Fields and Assign VariablesVariables are already set and want to unify the names.
Check Out How Get Records Can Be Used In Real Cases!
Use Case: Get a List of Names of Related Records to a Field
A while ago we published a Use Case to create ...
Read More
Use Case: Update All Related Contacts (Account Contact Relationship)
Do you have the Account Contact Relationship enabled for your ...
Read More
Use Case: Create an Easy Login Flow
Do you want to enforce the entry of certain user ...
Read More
Use Case: Clone Any Objects with Related Lists with Flow
"Clone with related" is an amazing feature which sadly is ...
Read More
Use Case: Simple Loop Example in Flow
Earlier we have published the how-to-guides on Loop and Counter, ...
Read More
Use Case: Mass Update Records From Related List #2
In this article we introduced the magical ids variable to ...
Read More
Use Case: Create Custom Roll-Up Summary With Flow
I have really mixed feelings about the roll-up summary field ...
Read More
Use Case: Update Contact After Logging Emails Or Calls
When I was a Salesforce admin, people asked me many ...
Read More
Use Case: Notify Owners When Case Merged Or Master Case Closed
I believe many are excited about the Case Merge release ...
Read More
Use Case: Clone Assets To Opportunity Products
I received this case to auto-create Opportunity Product or Quote ...
Read More

Official Salesforce Help Article On Get Records

Notify of
Inline Feedbacks
View all comments