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: Clone Opportunity Products To Assets
Last time we introduced a solution to clone Assets into ...
Read More
Use Case: Collection Sort To Calculate Upcoming 3 Opportunities
Today we will use this easy use case to illustrate ...
Read More
Flow: How To Use Custom Metadata Type
I am very excited about this case I received. I ...
Read More
Use Case: Update Order and Order Product Dates Quickly
If you are using order management, do you bump into ...
Read More

Official Salesforce Help Article On Get Records

Notify of
Inline Feedbacks
View all comments