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.
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
Field | Explanation |
---|---|
Variable | Put in the variable that you want to change the value, whether it is an existing resource or you want to create a new one. |
Operator | How the variable will be modified by the value. The available operators are dependent on your variable type. (See table below) |
Value | Can be either an existing resource or manually typed in values. |
Assignment Operators
Operator | Explanation | Available Variable Type |
---|---|---|
Equals | Entirely rewrite the variable with the value you assigned. | Text, Picklist, Number, Currency, Date, Date/Time, Collection |
Add | Add 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 |
Substract | Substract numbers or days. | Number, Currency, Date |
Equals Count | Equals 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 Start | As 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 |
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?
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
Hi, so is the field you want to update already exist in the Flow? If so, you can simply find that field and use the Equal operator. If not, you can use Update Records element to find the field and use Equal operator
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.