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
1.1

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
2.1

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
3.1

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

3 – 1. Automatically Store All Fields
3-1.1

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
3-2.1

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-2.2
3-2.3
3 – 3. Choose Fields and Assign Variables – When Get Only One Record
3-3.1

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
3-3.2

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
3-4.1

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

Official Salesforce Help Article On Get Records

Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
The boss

Hi

Are you sure about 3-1 vs 3-2
Reading this article https://metillium.com/2020/10/how-does-automatically-store-all-fields-option-work/ it seems you should always go for “Automatically Store All Fields”
Implying it’s not working slower and thus 3-2 option would not run your flow Faster.

What do you think?

Akram Aziz

What is a faster and better approach, using get records or selecting the object and conditions at the start of the flow? what is the difference?