Flow: How To Use “Assignment”

Assignment is the equal sign of flow (As you see in the icon). If you want to change the value of your variables, you will have to do it through Assignments.

flow assignment - setup

Some important notes before we dive into the details of Assignments:

1. Assignment Cannot Update Data Directly

If you have read my introduction of flow, you should know that Assignment is a logic element, so it does not have direct impact of your records. If you want to interact with your records, make sure you use a data element (Get, Create, Update, Delete).

2. Sometimes Assignment Can Be Skipped

Assignment is usually used for more complex operations (ex. in a loop or as a switch). If you simply want to change record fields, an Update Records element should be sufficient.

There are three main fields – Variable, Operator, and Value.

Assignment Fields

FieldExplanation
VariablePut in the variable that you want to change the value, whether it is an existing resource or you want to create a new one.
OperatorHow the variable will be modified by the value. The available operators are dependent on your variable type.
(See table below)
ValueCan be either an existing resource or manually typed in values.

Assignment Operators

OperatorExplanationAvailable Variable Type
EqualsEntirely rewrite the variable with the value you assigned.Text, Picklist, Number, Currency, Date, Date/Time, Collection
AddAdd numbers, add days, or add item to collections.
For text, the value will be appended at the end of the existing string. (Ex. AB+CD = ABCD)
Text, Picklist, Number, Currency, Date, Collection
SubstractSubstract numbers or days. Number, Currency, Date
Equals CountEquals Count = Equals + Count(Value), a count function included in the operator.

It counts how many items for only stages or collections.
(Ex. Col1 = [A, B, C], Count(Col1) = 3)
Number
Collections Only:
Add at StartAs opposed to “Add” which add items at the end, “Add at Start” will add from the start of the collection.Collection
Remove All + [Value],
Remove First + [Value],
Remove After First + [Value],
Remove Before First + [Value]
Take these four as a group, and consider the whole formula semantic.
(Ex. Col2 = [D, E, F, G]
Remove After First “E” = Remove all the items after the first “E” in this collection. NewCol = [D, E])
Collection
Remove Position + [Number]Each item in a collection has their own position number (index), starting from 1.

(Ex. Col3 = [H, I, J,]
Remove Position 2 (I)
New Col = [H, J]
Collection
Remove Uncommon + [Collections]Compare two collections and only keep those items that exist in both collections.

(Ex. Col4 = [K, L, M, N]
Col5 = [K, N, O]
NewCol = [K, N])
Collection
There is a comprehensive article from Salesforce Help about each operator. Check this out!
Check Out How Assignment Can Be Used In Real Cases!
Use Case: Simple Loop Example in Flow
Earlier we have published the how-to-guides on Loop and Counter, ...
Use Case: Simple Counter Example in Flow
Earlier we have published the how-to guides on Loop and ...
Use Case: Mass Update Records From Related List #2
In this article we introduced the magical ids variable to ...
Use Case: Mass Update Records From Related List #1
Have you heard of inline editing? This is my favorite ...

Official Salesforce Help Article On Assignment

Subscribe
Notify of
guest

4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Sofia

I am building out a record triggered task flow that uses a formula to update a field on the task. In the formula, I am using some lead record fields and used a get record element. I am trying to then populate that same value from the formula task to the lead. I came across your blog after trying to understand what I was doing wrong, currently I am using an assignment element to try to map the value from the formula to the lead field. Although, it works when I debug it doesn’t actually save the value on the record. Based on “1. Assignment Cannot Update Data Directly” on your blog I learned this is not possible, the introduction of flow link is not working for me, is that information available?

ARchana

Hi,

I want to assign a text variable to wo.serviceTerritory.SeriveResource. Can you please suggest me how can I do it with the Assignment component in flow ?Thanks

Nicole

Just want to say thank you so much Melody for putting these valuable information here, really easy to understand!
There’s so much of effort that you’ve put into this blog. I really appreciate that you put the time and effort together to share your knowledge.

Last edited 1 year ago by Nicole