---
schema_version: "1"
id: aa917fd818dee5d515f3466f561ff01380186fd7618a34622fddae2ae8e30428
title: Assignment Element
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/flow_ref_elements_assignment.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements_assignment.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: ff693950f24c6f3822ad140d744c6bf56801952f203d49f4f98920cd2a2f07c9
description: Set values in variables, including collection variables, record variables, record collection variables, and global variables.
products:
  - Flow Builder
  - Salesforce Platform
release: "264"
---
# Assignment Element

Set values in variables, including collection variables, record variables, record collection variables, and global variables.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=platform.flow_ref_supported_editions.htm&amp;release=264.0.0&amp;type=5" title="Learn about the editions and user interfaces that support Flow Builder. Some Flow Builder features integrate with other Salesforce products that require additional licenses.">View supported editions.</a></td></tr></tbody></table>

## Usage

To update the value of a variable, add an Assignment element to your flow. Specify the API name of a variable, an operator, and the value to use.

To update the value of more than one variable in an Assignment element, click Add Assignment. For each row, specify the variable, the operator, and the value to assign. At run time, variable assignments are made consecutively in the order they're listed in the element.

 
| Field | Description |
| --- | --- |
| **Variable** | The API name of the variable you want to assign a value to. Select an existing variable, or create one. |
| **Operator** | The operation to perform for the assignment. The available operators depend on the data type of the specified **Variable**. See [Flow Operators in Assignment Elements](https://help.salesforce.com/s/articleView?id=platform.flow_ref_operators_assignment.htm&release=264.0.0&type=5 "Use Assignment element operators to change the value of a selected resource.") |
| **Value** | The value to use in the assignment or the API name of a resource that contains the value to use in the assignment. **Variable** and **Value** in the same row must have compatible data types. |

![Update a Record Variable and Add It to a Record Collection](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/images/icon_example.png)

Update a Record Variable and Add It to a Record Collection

To set the field values for a record variable and then add the record variable to a record collection, use an Assignment element on a Loop element's For Each path. To create all the records at the same time, use the record collection variable with a Create Records element outside of the loop.

This example updates the Account ID, Amount, Description, and Stage fields of the NewOpportunity record variable and then adds the record variable to the NewOpportunities record collection variable.

This example contains five variables:

- NewOpportunity: **Data Type** is Record and **Object** is Opportunity.
- AccountId: **Data Type** is Text.
- OpportunityAmount: **Data Type** is Currency.
- OpportunityDescription: **Data Type** is Text.
- NewOpportunites: **Data Type** is Record and **Object** is Opportunity. **Allows multiple values**is selected.

The Assignment element in this example has five rows:

- The first row sets the record variable's account ID to a variable value:
    - **Variable** is NewOpportunity > Account ID
    - **Operator** is Equals
    - **Value** is AccountId
- The second row sets the record variable's amount to a variable value:
    - **Variable** is NewOpportunity > Amount
    - **Operator** is Equals
    - **Value** is OpportunityAmount
- The third row sets the record variable's description to a variable value:
    - **Variable** is NewOpportunity > Description
    - **Operator** is Equals
    - **Value** is OpportunityDescription
- The fourth row sets the record variable's stage to a literal value from the picklist associated with the Stage field:
    - **Variable** is NewOpportunity > Stage
    - **Operator** is Equals
    - **Value** is Proposal
- The fifth row adds the record variable to the record variable collection:
    - **Variable** is NewOpportunities
    - **Operator** is Add
    - **Value** is NewOpportunity

**Here's an Assignment element that sets properties of an opportunity record variable and then adds the variable to an opportunities record collection**

![An Assignment element that sets properties of an opportunity record variable and then adds the variable to an opportunities record collection](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_ref_elements_assignment_example_1.png)

![Set the Value of an Error Message in a Fault Path](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/images/icon_example.png)

Set the Value of an Error Message in a Fault Path

To set a variable equal to a relevant error message, use an Assignment element on a Fault path. Next, use a Go To connector to go to a Screen element that displays errors to the flow user. The Screen element uses the variable from the Assignment element in a Display Text component.

This example sets the value of the ErrorMessage variable to a string that identifies the problem and what to do about it.

This example contains one variable: ErrorMessage where **Data Type** is Text.

This example contains one row:

- **Variable** is ErrorMessage
- **Operator** is Equals
- **Value** is We couldn't find a record with the specified record ID. Check the record ID and try again.

**Here's an Assignment element that sets the value of a variable to a literal string**

![An Assignment element that sets the value of a variable to a literal string](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_ref_elements_assignment_example_2.png)

#### See Also

- [Flow Elements](https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements.htm&release=264.0.0&type=5 "An element represents an action that the flow can run. Examples include reading or writing Salesforce data, displaying information and collecting data from flow users, runnning business logic, or manipulating data.")
- [Flow Operators in Assignment Elements](https://help.salesforce.com/s/articleView?id=platform.flow_ref_operators_assignment.htm&release=264.0.0&type=5 "Use Assignment element operators to change the value of a selected resource.")
- [Create Records Element](https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements_data_create.htm&release=264.0.0&type=5 "Create or update multiple Salesforce or Marketing Object records by using a record collection variable. Create or update exactly one Salesforce or Marketing Object record by using a record variable or other values from the flow.")
- [Loop Element](https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements_loop.htm&release=264.0.0&type=5 "Start a loop path for iterating over items in a collection variable. For each iteration, the flow temporarily stores the item in the loop variable. To run actions on each item’s field values, use other elements in the loop.")
- [Move and Connect Elements to Change a Flow Route](https://help.salesforce.com/s/articleView?id=platform.flow_build_logic_route_add.htm&release=264.0.0&type=5 "Identify which elements the flow runs and in what order by connecting the elements on your canvas together. To change the run order, move elements and add or remove connectors.")
- [Flow Resources](https://help.salesforce.com/s/articleView?id=platform.flow_ref_resources.htm&release=264.0.0&type=5 "Each resource represents a value that you can reference throughout the flow.")