The Assignment element is a simple yet confusing element. To be honest, this is one that always tripped me up. The easiest way for me to remember what an Assignment is, is to compare it to a Field Update. They have nearly the exact same functionality. Assignments are extremely valuable when you are doing any sort of calculations on a variable in your Flow. If you are using this with a Visual Flow then you could have a variable change based on the User’s selections in the Flow. You could also use this similarly to a Field Update based on different decisions and set the variable to a certain value. Also, you could have a query of records add to a variable their Amounts. Often people overlook that this can be used on non-numeric fields like checkboxes, picklists, and text fields. Knowing that can allow you to really customize your Flow to be very dynamic.
Where is the Assignment element? You can find the Assignment element under the LOGIC section of the Palette.
You have three different types of actions you can take with an Assignment. You can either change the value to a specific value using equals. And you can add or subtract to the value using one of those operators.
In the below example of an Assignment you can see that we are taking our variable Opportunity_Amount and adding the amount of all of the Chicken Sold to that variable.
Other possible uses:
- Setting a checkbox to be TRUE or FALSE.
- Setting a picklist value
- Setting a date or date/time value
The possibilities are endless (almost)! I also like to use Assignments when I am dealing with a Visual Flow that requires User Interaction. Typically there are many more ‘routes’ that a Flow can go down, and when you have one value split across more than one screen it can get busy. By assigning your screen input value to a variable, you can save a headache for the rest of your Flow by using one variable to cover all the different screens.
RECAP: Assignment elements are your FIELD UPDATES in a Flow. If you need to do any sort of updating to a variable, this is your one stop shop! You have the ability to make a variable EQUAL to a value, ADD to a value, or SUBTRACT a value from the variable.