If you’ve ever built a Salesforce Flow that needed to remember a value — like the name a user typed in, or the account a record belongs to — you’ve needed a flow variable. Variables are the memory of your flow: they hold data so you can pass it between elements, use it in decisions, and write it back to records.
Without variables, every flow element would work in isolation. With them, you can capture user input on a Screen, run a calculation in a Formula, make a branch decision based on the result, and finally update a record — all in one seamless Salesforce automation. Variables are what make that chain possible.
This guide covers every Salesforce Flow variable type, how to create and configure variables in Flow Builder, how to assign values, and the best practices that keep your flows clean and maintainable. Whether you’re new to Flow or optimizing an existing process, you’ll leave with a complete understanding of how variables work.
Types of Salesforce Flow Variable
Salesforce Flow offers several types of Flow Variables, each designed to handle a specific type of data. Understanding the different types of Flow Variables is essential for creating effective and efficient flows. Here are the most common types of Flow Variables:

1. Text Variables
Text Variables store alphanumeric data — names, addresses, email addresses, or any free-form string. They’re the most commonly used variable type. Use them whenever you need to capture or pass a text value between flow elements, like storing a user’s input from a Screen element or building a dynamic email subject line.
2. Record Variables
Record Variables store a single Salesforce record with all its fields. When you use a Get Records element set to return “Only the first record,” the result is stored in a record variable. You can then reference individual fields — for example, {!varAccount.Name} or {!varAccount.Industry}. Think of a record variable as a single row from a database table.
3. Number Variables
Number Variables store numeric data such as quantities, counts, or percentages. They support decimal places (you set the scale when creating the variable). Use them in formulas and assignments for calculations — for example, counting how many records a loop has processed or computing a discount percentage.
4. Currency Variables
Currency Variables store monetary values with decimal precision. They automatically respect your org’s currency locale settings, so they display with the correct currency symbol and decimal format. Use them when working with financial data like deal amounts, invoice totals, or refund values.
5. Boolean Variables
Boolean Variables store true or false values. They’re ideal for flags and toggles — for example, tracking whether a record has been approved, whether a checkbox should be checked, or controlling which branch a Decision element should follow. Default value is typically false.
6. Date Variables
Date Variables store a date without a time component (e.g., 2026-09-22). Use them for contract start dates, birthdays, or any value where time of day doesn’t matter. If you also need to capture hours and minutes, use a Date/Time Variable instead.
7. Date/Time Variables
Date/Time Variables store both a date and a timestamp (e.g., 2026-09-22T15:30:00Z). Use them for appointment scheduling, SLA deadlines, or any field where the exact time matters. They store values in UTC and display in the user’s local timezone.
8. Picklist Variables
Picklist Variables store a single picklist selection as a text string. They’re useful for capturing a user’s choice from a Screen element dropdown or for storing a record’s picklist field value. Note that even though picklists appear as dropdowns, the variable stores the selected value as plain text.
9. Multi-Select Picklist Variables
Multi-Select Picklist Variables store multiple selected values as a single semicolon-separated string (e.g., "Option A;Option B;Option C"). Use them when a user or record needs to hold more than one picklist selection. You’ll often need formulas or Apex to parse individual values from the string.
10. Apex-Defined Variables
Apex-Defined Variables store custom data structures defined by an Apex class. They’re used for complex data shapes that standard variable types can’t represent — like a nested object with multiple fields returned from an API callout or a custom data wrapper class. You’ll need a developer to create the backing Apex class.
11. Collection Variables
Collection Variables store multiple values of the same type — either a list of primitives (like a collection of Text values) or a list of records (a record collection). When you use a Get Records element set to return “All records,” the result is stored in a record collection variable. Use collections with Loop elements to process multiple records, or with Assignment elements to add and remove items.
By using the appropriate type of Flow Variable, you can ensure that your flow processes data in the most efficient way possible.
Creating Flow Variables
Creating Flow Variables in Salesforce Flow is a straightforward process. Here are the steps to create a Flow Variable:
Total Time: 10 minutes
Go to Setup & Navigate to Flows

Go to Setup (click the gear icon), then use the Quick Find box to search for “Flows.”
Click on “Flows” from the results.
Click the “New Flow” button in the upper right corner.
Select Flow Type


When you create a new Flow in Salesforce, you first see a screen that shows four main automation categories.
Choose a Flow Categories (eg. Screen Automations).
Select the type that matches your needs (eg. Screen Flow).
Show Toggle Toolbox

Click on Toggle Toolbox icon
to display the Toolbox.
Create New Variable

To add variable, Click on the New Resource button in the Properties pane.
Select Variable Type

Choose the type of variable you want to create from the drop-down list then click Done.
Fill Details

Enter a name for the variable in the “Name” field.
Use a clear and descriptive name that indicates what the variable is used for.
Click Done to create the variable.
Note : (Optional) Enter a default value for the variable. This value will be used if no other value is provided during flow execution.
Find Newly Create Flow Variable

Now you have a container to store data. You can find it in the Toolbox.
Here are some best practices for creating Flow Variables in Salesforce Flow:
- Use meaningful names for your variables. This will make it easier to understand what data the variable is storing.
- Use the appropriate data type for your variables. For example, if you’re storing a number, use the “Number” data type.
- Keep your variables organized. You can group your variables into categories to make them easier to find and manage.
- Avoid creating too many variables. Having too many variables can make your Salesforce Flow more complex and difficult to manage.
Once you have created a Flow Variable, it can be used throughout the flow to store and manipulate data.
Assigning Values to Flow Variables
Once you have created a Flow Variable in Salesforce Flow, you can assign a value to it. The value assigned to a Flow Variable can come from user input, record fields, or formulas. Here are some ways to assign values to Flow Variables:
1.Using formulas
You can use formulas to calculate and assign values to Flow Variables. Formulas can be used to perform mathematical operations, concatenate text values, or manipulate date/time values.

2.Setting values from record fields
You can set the value of a Flow Variable to a specific field value from a record. This is useful when you want to extract information from a record and use it elsewhere in the flow.

3.Setting values from user input
You can capture user input and use it to set the value of a Flow Variable. This is useful when you need to gather information from the user in order to complete a flow process.

By assigning values to Flow Variables, you can store and manipulate data in a dynamic and flexible way.
4.Using the Assignment Element
The Assignment element is the most commonly used way to set or update variable values.
With an Assignment element, you can:
- Set a value (for example, assign a fixed value or copy data from another field)
- Add or subtract values, which is useful for counters or calculations
- Append values to collections, such as adding records to a collection variable

Assignment elements are essential when you need to manipulate data during the flow execution. In the next section, we will explore how to use Flow Variables in Salesforce Flow.
Use Flow Variables in Salesforce Flow

Using Flow Variables in Salesforce Flow is an essential part of building effective and efficient automation processes. Flow Variables can be used in a variety of elements throughout the flow, including screen elements, decision elements, update elements, and Apex actions. Here are some examples of how to use Flow Variables in each of these elements:
Screen elements
Screen elements allow you to create user interfaces for your flow. You can use Flow Variables to prepopulate fields or provide default values for input fields.
Decision elements
Decision elements allow you to make conditional decisions based on the data in a Flow Variable. For example, you can use a decision element to determine whether a record meets certain criteria before updating it.
Update elements
Update elements allow you to update records based on the data in a Flow Variable. For example, you can use an update element to set the stage of an opportunity in Salesforce based on the user input captured in a Flow Variable.
Apex actions
Apex actions allow you to execute custom Apex code in your flow — useful for advanced tasks like sending templated emails, calling external APIs, or even generating a PDF in Salesforce.
By using Flow Variables in these elements, you can create dynamic and flexible flows that meet your business needs.
Salesforce Flow Loop Example
A common use case for loops in Salesforce Flow is to process multiple records in a collection. For example, let’s say you have a collection of accounts that need to be updated with a specific value. You can use a loop to iterate through each account in the collection and update the value for each record.
To create a loop in Salesforce Flow, use the Loop element. The Loop element iterates through each record in a collection variable, one at a time. For each iteration, Flow assigns the current record to a loop variable that you can reference in subsequent elements. The loop ends automatically when all records in the collection have been processed.
Here’s an example of a For Loop in Salesforce Flow:
- Create a new Flow and add a Screen element to collect user input.
- Add a Get Records element to retrieve a collection of accounts.
- Add a For Loop element and specify the collection of accounts to iterate through.
- Add an Update Records element to update each account in the collection.
- Add a Screen element to display a message to the user when the loop is complete.

In this example, the For Loop iterates through each account in the collection and updates a specific field for each record. Once the loop is complete, a message is displayed to the user indicating that the operation was successful.
Salesforce Flow Global Variables
Global variables are system-provided values that Salesforce makes available in every flow — you don’t create them yourself. They give your flow access to context about the running user, the current record, the organization, and more. Common global variables include:
- $Record — The record that triggered the flow (in Record-Triggered Flows)
- $Record__Prior — The record’s field values before the triggering change
- $User — The running user’s details (name, email, profile, role)
- $Api — API session information for external callouts via the Salesforce REST API
- $Flow.CurrentDate / $Flow.CurrentDateTime — Today’s date or current timestamp
- $Organization — Org-level info like name, locale, and currency
- $Profile — The current user’s profile name and ID
You reference global variables using the {!$GlobalVariable.FieldName} syntax. For example, {!$User.FirstName} returns the running user’s first name, and {!$Record.Amount} returns the Amount field of the triggering record.
https://help.salesforce.com/s/articleView?id=sf.flow_ref_resources_global_variables.htm&type=5
Here are some advantages and disadvantages of using global variables in Salesforce Flow:
Advantages:
- Global variables can be accessed from any element in your Salesforce Flow, making it easy to pass data between different elements.
- Global variables can be used to store values that need to be accessed by multiple elements, reducing the need to create duplicate Flow Variables.
Disadvantages:
- Global variables can make your Salesforce Flow more complex, especially if you have a large number of global variables.
- Global variables can make it more difficult to understand how data is being passed between different elements in your Salesforce Flow.
When using global variables in Salesforce Flow, it’s important to follow best practices to ensure that your Flow is organized and easy to understand. Here are some tips for using global variables in Salesforce Flow:
- Use meaningful names for your global variables to make it easy to understand what data they are storing.
- Only create global variables when you need to pass data between different sub-flows or when you need to store a value that needs to be accessed by multiple elements.
- Be mindful of the number of global variables you create. Creating too many global variables can make your Salesforce Flow more complex and difficult to understand.
In summary, global variables are a powerful tool in Salesforce Flow that can be used to pass data between different elements and reduce the need to create duplicate Flow Variables. When using global variables, it’s important to follow best practices to ensure that your Salesforce Flow is organized and easy to understand.
Best Practices for Using Flow Variables in Salesforce Flow

To ensure that your Salesforce Flow processes run smoothly and efficiently, it’s important to follow best practices when using Flow Variables. Here are some tips for using Flow Variables effectively:
Use clear and descriptive names for your variables
This will make it easier to understand what the variable is used for and how it should be used in the flow.
Keep variables as narrow in scope as possible
Don’t create variables that are too broad in scope, as this can lead to confusion and errors. Instead, create variables that are specific to a particular task or process.
Avoid using too many variables
While variables can be useful, using too many of them can make your flow more complex and harder to understand. Try to keep the number of variables to a minimum.
Use consistent naming conventions
This will help you and other users to quickly identify and understand the purpose of each variable.
Use default values where appropriate
Default values can help to streamline your flow by providing a starting point for data when no other value is provided.
Test your flow thoroughly in a Salesforce sandbox
Before deploying your flow to production, be sure to test it thoroughly to ensure that all variables are working correctly.
By following these best practices, you can ensure that your Salesforce Flow processes are efficient, effective, and easy to maintain.
Conclusion
Here are the key things to remember about Salesforce Flow Variables:
- Variables are the glue between elements — they store data so elements can share it. Without variables, each element operates in isolation.
- Match the type to your data — use Text for strings, Number for counts, Currency for money, Record for a single record, and Collection for a list. Choosing the wrong type causes assignment errors.
- Record Variables hold one record; Collection Variables hold many — use Collection Variables with Loop elements when processing multiple records.
- Set Input/Output availability intentionally — “Available for Input” lets callers pass a value in; “Available for Output” lets the flow return a value. Only check what you actually need.
- Global variables ($Record, $User, $Flow.CurrentDate) are system-provided — you reference them, you don’t create them. Never recreate what Salesforce already gives you.
- Always test in a sandbox first — activate flows in a Salesforce sandbox before deploying to production to catch variable assignment errors safely.
Need help designing or debugging a Salesforce Flow? Let’s talk →
Create a Variable Unit | Salesforce Trailhead
FAQs
What is a variable in Salesforce Flow?
A variable in Salesforce Flow is a named container that stores a piece of data — text, a number, a date, a full record, or even a list of records — so you can use it throughout your flow’s logic. Variables let you capture user input on a Screen element, hold the result of a Get Records lookup, pass values into formulas, and write data back to Salesforce records. Every flow that does more than a single static action needs at least one variable.
What is the difference between a Record Variable and a Collection Variable?
A Record Variable holds a single Salesforce record (for example, one Account or one Contact). A Collection Variable holds a list of multiple records of the same object type. Use a Record Variable when your Get Records element returns “Only the first record,” and use a Collection Variable when it returns “All records.” To process each item in a collection, you pass it into a Loop element — you cannot loop over a single record variable.
How do I pass variables between Salesforce Flows?
To pass variables between flows, you use the Input/Output availability settings. In the child flow (subflow), set the variable to “Available for Input” to receive a value, or “Available for Output” to send a value back. Then in the parent flow, add a Subflow element, select the child flow, and map your parent flow’s variables to the child flow’s input/output variables. Only variables explicitly marked as Available for Input or Output will appear in the mapping screen.
What are global variables in Salesforce Flow?
Global variables are system-provided values that Salesforce makes available in every flow automatically — you don’t create them yourself. The most common ones are $Record (the record that triggered a Record-Triggered Flow), $User (the running user’s details like name and email), $Flow.CurrentDate and $Flow.CurrentDateTime (today’s date or the current timestamp), and $Organization (org-level settings). You reference them using merge field syntax, for example {!$User.FirstName}.
Can I use flow variables in formulas?
Yes. In Flow Builder, create a Formula resource and reference your variables using the {!variableName} merge field syntax. For example, if you have a Currency variable called varAmount, you can write a formula like IF({!varAmount} > 5000, “High”, “Standard”) to return a text value based on the amount. The formula result is stored as its own resource that you can then assign to another variable or use in a Decision element.