Skip to content

Set Variable

The set variable action

The Set Variable action allows you to define and assign values to variables within your web app.

Note

In order to use this After-Action, you first need to create a variable.

How it works

Once you've selected the variable you want to update, you need to set a value using the Function editor, like so:

js
return true;

This code will set the value of the variable to true.

When to use Set Variable

Variables in web app development act as containers for storing and managing data.

The Set Variable action is particularly useful for various scenarios, such as:

  • Dynamic Content: Use variables to dynamically change content on your app based on user interactions or backend data.

  • Iterating over a list: Use variables to keep count of the current item in a list.

  • Data manipulation: When users input data, store it in a variable for easy access and manipulation.

  • Conditional Logic: Variables are handy for storing and evaluating conditions within your app, enabling dynamic decision-making.

  • Temporary Storage: If you need to temporarily store data while the user is on the page, variables are a great choice.

  • Filtering and Sorting: Computed variables are great for filtering and sorting data from your backend.

Aside from these use cases, variables provide flexibility and efficiency in managing data throughout your web app.

For more information about Variables, refer to our Variables documentation in the Data Store.