Overview
The Set Variable Action is used to change the value of a Variable based on the value of any other Variable or Airscript expression. It has many uses, including setting the validation state of a form to TRUE or FALSE based on user input, or combining two different values from a form.
Use Cases
- Variables can be used to track whether a user's entry is valid and modify the UI appropriately, as seen in Validation of Forms & User Data.
- A Variable can be used as the text value of a Label, and changed dynamically using the Set Variable Action.
- The Set Variable Action can be used to consolidate data to be used in a Data Flow. For instance, if the user enters their email in one Web Flow, the Set Variable Action can be used to save it to the session, with
session.user_email = activity.user_email
.- If the user later opens a new Web Flow to escalate their case, the
session.user_email
Variable can then be passed into a Data Flow to create a Zendesk Ticket populated with the user's information.
- If the user later opens a new Web Flow to escalate their case, the
- The Set Variable Action can be used to bind two controls together. For instance, a Map component and a Place Search Input component could be bound together.
- When the user scrolls the Map, the Place Search Input updates to the new address under the marker.
- When the user types an address into the Place Search Input, the Map scrolls to center on the new address.
Action Properties
Variable
The Variable whose value will be changed by this action.
Value
The new value for the specified Variable. The value can be any Airscript expression, including the original Variable itself, or any Airscript function that returns the same type as the Variable.
In the example below, email_is_valid
will be set to TRUE if the email_input
Variable contains a valid email, or FALSE if it does not.