目次
Introduction.
For those just beginning to use Salesforce flows, the concept of “variables” may seem a bit abstract. However, it is important to understand the basics of variables in order to effectively utilize flows.
This article explains “variables” and “collection variables” in the Salesforce flow and introduces points for making full use of them. Specific examples will be used to make it easier for flow beginners to understand.
1. What are Variables?
1-1. Basic Concept of Variables
A variable is like a “container” for temporarily storing data. It is like a “box” in programming, which stores various values in a Salesforce flow and can be referenced or changed later.
In a Salesforce flow, for example, you can store the following types of data as variables
- String (text)
- Numeric values
- Dates and times
- Records (e.g., business partners, business meetings, etc.)
- True/False (Boolean)
1-2. How to create variables
To create a variable, follow these steps
- Open the Flow Builder
- Select “New Resource” from the button in the upper left corner of the screen (to the left of the Select Element button)
- Select “Variable” as the resource type
- Set the properties of the variable
- API reference name: Name of the variable (e.g.
recordId
) - Data type: type of data to store (e.g., text, number, record, etc.)
- Default value (optional): initial value can be set
- Availability (optional): limits input/output
- API reference name: Name of the variable (e.g.
Now you can keep data in the flow.
2. What are Collection Variables?
2-1. Basic Concept of Collection Variables
A collection variable is “a variable that can store multiple data together. While a normal variable can only hold one value, a collection variable can manage multiple data like a list. For example, multiple rows of data entered in the Name, Phone Number, and Email fields in an Excel row can be grouped together and stored in a collection variable.
- I want to retrieve and process a batch of business meetings (Opportunity).
- I want to keep a list of contact persons (Contact).
- I want to manage several values as a list.
You can use collection variables in such cases.
In Excel’s “Customer List,” each row contains the name, e-mail address, phone number, etc., of each customer. This “list of rows” corresponds to a collection variable in the Salesforce flow. So, you can think of a collection variable as a chunk of data stored in multiple rows of Excel.

2-2. how to create a collection variable
As with regular variables, you can create a collection variable by following the steps below.
- Open the Flow Builder
- Select “New Resource
- Select “Variable” in “Resource Type
- Set “Data Type” (e.g., Text, Record, etc.)
- Check the “Allow multiple values” checkbox.
This will create a collection variable that can store multiple data.
3. Examples of Variable and Collection Variable Usage
3-1. Example of Variable Usage: Temporarily storing user input data
For example, consider a case where a user inputs his/her name in a screen flow, which is then displayed on a later screen.
- User enters name
- Stores it invariable
userName
(data type: text) - On the next screen, “Hello, {userName}! is displayed on the next screen
In this way, by using variables, the user’s input can be utilized in the flow. 3-2.
3-2. Example of Collection Variable Usage: Storing data like a list of Excel rows
Collection variables are useful when handling multiple data together like rows of Excel.
Example: Retrieving a list of business partner responsibilities (Contact) and displaying them as a list
- Retrieve all contact persons (Contacts) associated with a business partner
- Store them in thecollection variable
contactList
(data type: record) - Display the list on the screen for the user to select
As you can see, collection variables serve a similar function to Excel’s “list of rows” and are suitable for managing multiple data. This is a deep subject, so I will explain it in more detail at another time.
4. Using Variables and Collection Variables
Item | Variable | Collection Variable |
---|---|---|
Amount of data that can be stored | Single data | Multiple data (list) |
Typical uses | Storage of user input, temporary retention of calculation results | Storage of data in list format, management of multiple items |
Main operations | Assign, reference | Add, delete, and list operations |
If you remember that a variable is used to handle only one value, and a collection variable is used to handle multiple values, you can use both without hesitation.
5. Conclusion
Variables and collection variables are indispensable elements when using Salesforce Flow.
- A variable is like a “box” that stores a single piece of data
- Collection variables are like a “list of rows” in Excel
- Variables are for single data processing, while collection variables are for list data management
By utilizing the appropriate variables when creating a flow, a more flexible and efficient design can be achieved. Please make use of the contents of this presentation to learn while actually creating a flow!