Loading
Prepare for Email to Become the Default Login ExperienceRead More
Intermittent freezing when using using certain browser versionsRead More
Automate Your Business Processes with Salesforce Flow
Flow Operators in Assignment Elements

Flow Operators in Assignment Elements

Use Assignment element operators to change the value of a selected resource.

Required Editions

View supported editions.

Use this reference to understand the supported operators. The reference organizes operators by the data type you select for Resource.

Tip
Tip The Contains operator isn't available for Assignment elements. To check whether a value contains another value, use a Decision or Collection Filter element. You can also use Contains as a filter condition in a data element or record choice set. See Flow Operators in Decision, Wait, and Collection Filter Elements or Flow Operators in Data Elements and Record Choice Sets.

Apex-Defined

Match the @AuraEnabled attribute’s Apex data type with a flow data type in this reference to find which operators the flow supports.

Apex Data Type Flow Data Type
Boolean Boolean
Date Date
DateTime Date/Time
Decimal Number
Double Number
Integer Number
List Collection
Long Number
String Text
Time Time

Boolean

Replace a Boolean resource with a new value.

Operator Description Supported Data Types Example
Equals What you enter or select for Value replaces the value of Variable. Boolean

Before Assignment: {!varBoolean} is false

Assignment: {!varBoolean} Equals {!$GlobalConstant.True}

After Assignment: {!varBoolean} is true

Collection

Update or replace the value of a collection variable or record collection variable.

Operator Description Supported Data Types Example
Equals Value replaces the value of Variable.

Collection of the same data type or object type

Text, Picklist, and Multi-Select Picklist data types are compatible with each other.

Before the Assignment:

  • {!collText} is Yellow, Green, Blue
  • {!collPicklist} is Blue, Red, Orange

Assignment: {!collText} Equals {!collPicklist}

After the Assignment: {!collText} is Blue, Red, Orange

Add Appends Value as a new item to the end of the collection in Variable.

Variable of the same data type or record variable of the same object type

Text, Picklist, and Multi-Select Picklist data types are compatible with each other.

You can also add stages (including $Flow.CurrentStage) to text collections.

Before the Assignment:

  • {!collText} is Yellow, Green, Blue
  • {!varPicklist} is Red

Assignment: {!collText} Add {!varPicklist}

After the Assignment: {!collText} is Yellow, Green, Blue, Red

Remove After First Finds the first instance of Value in the collection in Variable and removes all items after it.

Variable of the same data type or record variable of the same object type

For text collections only:

  • Multi-Select Picklist
  • Picklist
  • $Flow.CurrentRecord

Before the Assignment:

  • {!collText} is Red, Orange, Yellow, Green, Blue
  • {!varText} is Yellow

Assignment: {!collText} Remove After First {!varText}

After the Assignment: {!collText} is Red, Orange, Yellow

Add At Start Appends Value as a new item to the beginning of the collection in Variable.

Collection of the same data type or object type

Variable of the same data type or record variable of the same object type

For text collections only:

  • Multi-Select Picklist
  • Picklist
  • $Flow.CurrentRecord

Before the Assignment:

  • {!collText} is Yellow, Green, Blue
  • {!varPicklist} is Red

Assignment: {!collText} Add At Start {!varPicklist}

After the Assignment: {!collText} is Red, Yellow, Green, Blue

Remove All Removes all instances of Value from the collection in Variable.

Collection of the same data type or object type

Variable of the same data type or record variable of the same object type

For text collections only:

  • Multi-Select Picklist
  • Picklist
  • $Flow.CurrentRecord

Before the Assignment:

  • {!collText} is Red, Orange, Red, Yellow
  • {!varText} is Red

Assignment: {!collText} Remove All {!varText}

After the Assignment: {!collText} is Orange, Yellow

Remove First Removes the first instance of Value from the collection in Variable.

Collection of the same data type or object type

For text collections only:

  • Multi-Select Picklist
  • Picklist
  • $Flow.CurrentRecord

Before the Assignment:

  • {!collText} is Red, Orange, Red, Yellow
  • {!varText} is Red

Assignment: {!collText} Remove First {!varText}

After the Assignment: {!collText} is Orange, Red, Yellow

Remove Before First Finds the first instance of Value in the collection in Variable and removes all items before it.

Variable of the same data type or record variable of the same object type

For text collections only:

  • Multi-Select Picklist
  • Picklist
  • $Flow.CurrentRecord

Before the Assignment:

  • {!collText} is Red, Orange, Yellow, Green, Blue
  • {!varText} is Yellow

Assignment: {!collText} Remove Before First {!varText}

After the Assignment: {!collText} is Yellow, Green, Blue

Remove Position

Removes the item at the position that you enter for Value from the collection in Variable.

Make sure that Value at run time is a positive integer that's within the range of the number of items in the collection in Variable.

Number

Before the Assignment:

  • {!collText} is Red, Orange, Yellow
  • {!varNum} is 2

Assignment: {!collText} Remove Position {!varNum}

After the Assignment: {!collText} is Red, Yellow

Remove Uncommon Keeps only the items in Variable that match items in Value and removes all others. Collection of the same data type or object type

Before the Assignment:

  • {!collText1} is Red, Orange, Yellow, Green
  • {!collText2} is Orange, Green, Blue

Assignment: {!collText1} Remove Uncommon {!collText2}

After the Assignment: {!collText1} is Orange, Green

Equals Count

The number of stages or collection items in what you enter for Value replaces the value of Variable.

Record choice sets aren't supported as a value.

  • Collection
  • $Flow.ActiveStages

Before the Assignment:

  • {!varNumber} is 0
  • {!collText} is Yellow, Green, Blue

Assignment: {!varNumber} Equals Count {!collText}

After the Assignment: {!varNumber} is 3

Currency and Number

Replace (Equals), add to (Add), or subtract from (Subtract) the value of a currency or number resource. Count (Equals Count) the number of active stages or the number of items in a collection.

Operator Description Supported Data Types Example
Equals The number that you enter or select for Value replaces the value of Variable.
  • Currency
  • Number

Before the Assignment: {!varCurrency} is 10

Assignment: {!varCurrency} Equals 7

After the Assignment: {!varCurrency} is 7

Add Adds the number that you enter or select for Value to the value of Variable.
  • Currency
  • Number

Before the Assignment: {!varCurrency} is 10

Assignment: {!varCurrency} Add 7

After the Assignment: {!varCurrency} is 17

Subtract Subtracts the number that you enter or select for Value from the value of Variable.
  • Currency
  • Number

Before the Assignment: {!varCurrency} is 10

Assignment: {!varCurrency} Subtract 7

After the Assignment: {!varCurrency} is 3

Date

Replace (Equals), add to (Add), or subtract from (Subtract) the value of a date/time resource.

Tip
Tip To add or subtract days from today's date, set Variable to {!$Flow.CurrentDate} and use the Add or Subtract operator. For example, to calculate a date 7 days from today, assign {!$Flow.CurrentDate} Add 7 to your date variable.
Operator Description Supported Data Types Example
Equals The date that you enter or select for Value replaces the value of Variable.
  • Date
  • Date/Time

Example 1: Set to a specific date:

Before the assignment: {!varDate} is 1/16/2016

Assignment: {!varDate} Equals 1/15/2016

After the assignment: {!varDate} is 1/15/2016

Example 2: Set to today’s date:

Before the assignment: {!varDate} is 1/16/2016

Assignment: {!varDate} Equals {!$Flow.CurrentDate}

After the assignment: {!varDate} is today’s date

Add Adds Value in days to Variable’s value.
  • Currency
  • Number

Example 1: Add days to a specific date:

Before the assignment: {!varDate} is 1/16/2016

Assignment: {!varDate} Add 7

After the assignment: {!varDate} is 1/23/2016

Example 2: Add days to today’s date:

Before the assignment: {!varDate} is today’s date

Assignment: {!varDate} Add 7

After the assignment: {!varDate} is today’s date plus 7 days

Subtract Subtracts Value in days from Variable’s value.
  • Currency
  • Number

Example 1: Subtract days from a specific date:

Before the assignment: {!varDate} is 1/16/2016

Assignment: {!varDate} Subtract 7

After the assignment: {!varDate} is 1/9/2016

Example 2: Subtract days from today’s date:

Before the assignment: {!varDate} is today’s date

Assignment: {!varDate} Subtract 7

After the assignment: {!varDate} is today’s date minus 7 days

Date/Time

Replace a date/time resource with a new value (Equals).

Operator Description Supported Data Types Example
Equals The date that you enter or select for Value replaces the value of Variable.
  • Date
  • Date/Time

Before the Assignment: {!varDateTime} is 1/16/2016 01:00

Assignment: {!varDateTime} Equals 1/16/2016 08:00

After the Assignment: {!varDateTime} is 1/16/2016 08:00

Picklist

Replace a picklist resource with a new value (Equals) or concatenate a value onto the original value (Add).

Note
Note Flow converts values to strings before assigning or adding them to the picklist resource.
Operator Description Supported Data Types Example
Equals What you enter or select for Value replaces the value of the selected picklist.
  • Boolean
  • Currency
  • Date
  • Date/Time
  • Multi-Select Picklist
  • Number
  • Picklist
  • Text
  • Stage
  • Time

Before the Assignment: {!varPicklist} is Blue

Assignment: {!varPicklist} Equals Yellow

After the Assignment: {!varPicklist} is Yellow

Add Appends what you enter or select for Value to the end of the selected picklist.
  • Boolean
  • Currency
  • Date
  • Date/Time
  • Multi-Select Picklist
  • Number
  • Picklist
  • Text
  • Stage
  • Time

Before the Assignment: {!varPicklist} is Blue

Assignment: {!varPicklist} Add -green

After the Assignment: {!varPicklist} is Blue-green

Multi-Select Picklist

Replace a multi-select picklist resource with a new value (Equals), concatenate a value onto the original value (Add), or add a selection to the resource (Add Item).

Note
Note Flow converts values to strings before assigning or adding them to the multi-select picklist resource.
Operator Description Supported Data Types Example
Equals What you enter or select for Value replaces the value of the selected multi-select picklist.
  • Boolean
  • Collection
  • Currency
  • Date
  • Date/Time
  • Multi-Select Picklist
  • Number
  • Picklist
  • Text
  • Stage
  • Time

Before the Assignment: {!varMSP} is Blue

Assignment: {!varMSP} Equals Yellow

After the Assignment: {!varMSP} is Yellow

Add

Appends what you enter or select for Value to the last selected item in the multi-select picklist. The Add operator doesn’t create a selection.

To add items as new selections, use the Add Item operator.

To add semi-colon-delimited items to a multi-select picklist variable with the Add operator, always add a single space after the semi-colon and don’t include a space before the semi-colon. This way, the variable’s values match the values of multi-select picklist fields in Salesforce. For example: ; Yellow

  • Boolean
  • Currency
  • Date
  • Date/Time
  • Multi-Select Picklist
  • Number
  • Picklist
  • Text
  • Stage
  • Time

Before the Assignment: {!varMSP} is Blue; Green. This value includes two separate selections

Assignment: {!varMSP} Add Yellow

After the Assignment: {!varMSP} is Blue; GreenYellow. This value includes two separate selections

Add Item Adds what you enter or select for Value as a new selection to the end of the multi-select picklist. The Assignment automatically adds “;” before the new item. That way, Salesforce treats it as a separate selection.
  • Boolean
  • Currency
  • Date
  • Date/Time
  • Multi-Select Picklist
  • Number
  • Picklist
  • Text
  • Time

Before the Assignment: {!varMSP} is Blue; Green

Assignment: {!varMSP} Add item Yellow

After the Assignment: {!varMSP} is Blue; Green; Yellow. This value includes three separate selections

Record

Replace a record variable with a new value (Equals).

Operator Description Supported Data Types Example
Equals The record variable that you select for Value replaces the value of Variable. Record – with the same object type

Before the Assignment:

  • {!account1} contains field values for the Acme Wireless account
  • {!account2} contains field values for the Global Media account

Assignment: {!account1} Equals {!account2}

After the Assignment: both {!account1} and {!account2} contain the field values for the Global Media account

Stage

You can’t update the value of a stage, but you can update the values of the stage global variables: $Flow.CurrentStage and $Flow.ActiveStages.

Note
Note Assignments use the stage’s fully qualified name: namespace.flowName:stageName or flowName:stageName.

$Flow.CurrentStage

Replace the stage selected in $Flow.CurrentStage.

Operator Description Supported Data Types Example
Equals Value replaces the value of $Flow.CurrentStage.
  • Stage
  • Fully qualified stage name

Before the Assignment: $Flow.CurrentStage is stage1

Assignment: {!$Flow.CurrentStage} Equals {!stage2}

After the Assignment: $Flow.CurrentStage is stage2

$Flow.ActiveStages

Add or remove active stages in the $Flow.ActiveStages global variable.

Operator Description Supported Data Types Example
Add Appends Value to the end of $Flow.ActiveStages.
  • Stage
  • $Flow.ActiveStages
  • $Flow.CurrentStage
  • Fully qualified stage name

Before the Assignment: $Flow.ActiveStages is stage1, stage2

Assignment: {!$Flow.ActiveStages} Add {!stage3}

After the Assignment: $Flow.ActiveStages is stage1, stage2, stage3

Remove After First Finds the first instance of the stage in Value within $Flow.ActiveStages and removes all stages after it.
  • Stage
  • $Flow.CurrentStage
  • Fully qualified stage name

Before the Assignment: $Flow.ActiveStages is stage1, stage2, stage3, stage4

Assignment: {!$Flow.ActiveStages} Remove After First {!stage2}

After the Assignment: $Flow.ActiveStages is stage1, stage2

Add At Start Adds Value to the beginning of $Flow.ActiveStages.
  • Stage
  • $Flow.ActiveStages
  • $Flow.CurrentStage
  • Fully qualified stage name

Before the Assignment: $Flow.ActiveStages is stage1, stage2

Assignment: {!$Flow.ActiveStages} Add At Start {!stage0}

After the Assignment: $Flow.ActiveStages is stage0, stage1, stage2

Remove All Removes all instances of Value from $Flow.ActiveStages.
  • Stage
  • $Flow.ActiveStages
  • $Flow.CurrentStage
  • Fully qualified stage name

Before the Assignment: $Flow.ActiveStages is stage1, stage2, stage3

Assignment: {!$Flow.ActiveStages} Remove All {!$Flow.ActiveStages}

After the Assignment: $Flow.ActiveStages is empty

Remove First Removes the first instance of the stage in Value from $Flow.ActiveStages.
  • Stage
  • $Flow.CurrentStage
  • Fully qualified stage name

Before the Assignment: $Flow.ActiveStages is stage1, stage2, stage3, stage1

Assignment: {!$Flow.ActiveStages} Remove First stage1

After the Assignment: $Flow.ActiveStages is stage2, stage3, stage1

Remove Before First Finds the first instance of the stage in Value within $Flow.ActiveStages and removes all stages before it.
  • Stage
  • $Flow.CurrentStage
  • Fully qualified stage name

Before the Assignment: $Flow.ActiveStages is stage1, stage2, stage3, stage4

Assignment: {!$Flow.ActiveStages} Remove Before First {!stage3}

After the Assignment: $Flow.ActiveStages is stage3, stage4

Remove Position

Removes the stage at the position that you enter for Value from $Flow.ActiveStages.

Make sure that Value at run time is a positive integer that is within the range of the number of stages in $Flow.ActiveStages.

Number

Before the Assignment:

  • $Flow.ActiveStages is stage1, stage2, stage3
  • {!varNum} is 2

Assignment: {!$Flow.ActiveStages} Remove Position {!varNum}

After the Assignment: $Flow.ActiveStages is stage1, stage3

Equals Count

The number of stages or collection items in what you enter for Value replaces the value of Variable.

Record choice sets aren't supported as a value.

  • Collection
  • $Flow.ActiveStages

Before the Assignment:

  • {!varNumber} is 0
  • {!collText} is Yellow, Green, Blue

Assignment: {!varNumber} Equals Count {!collText}

After the Assignment: {!varNumber} is 3

Text

Replace a text resource with a new value (Equals) or concatenate a value onto the end of the original value (Add).

Note
Note Flow converts values to strings before assigning or adding them to the text resource.
Operator Description Supported Data Types Example
Equals The text that you enter or select for Value replaces the value of Variable.
  • Boolean
  • Currency
  • Date
  • Date/Time
  • Number
  • Multi-Select picklist
  • Picklist
  • Stage, including $Flow.CurrentStage and $Flow.ActiveStages
  • Text
  • Time

Before the Assignment: {!varText} is Blue

Assignment: {!varText} Equals Yellow

After the Assignment: {!varText} is Yellow

Add Appends the text that you enter or select for Value to the end of Variable.
  • Boolean
  • Currency
  • Date
  • Date/Time
  • Number
  • Multi-Select picklist
  • Picklist
  • Stage, including $Flow.CurrentStage and $Flow.ActiveStages
  • Text
  • Time

Before the Assignment: {!varText} is Blue

Assignment: {!varText} Add Yellow

After the Assignment: {!varText} is BlueYellow

Time

Replace a time resource with a new value (Equals).

Operator Description Supported Data Types Example
Equals The time that you enter or select for Value replaces the value of Variable. Time

Before the Assignment:

{!varTime} is 09:00 AM

Assignment:

{!varTime} Equals 09:00 AM

After the Assignment:

{!varTime} is 09:00 AM

 
Loading
Salesforce Help | Article