Create a variable
Function: Create a variable
This action allows you to create a new variable within your application's scope. Variables are like temporary storage containers that hold information you can use throughout your application's logic. You can store any type of data in these variables, such as text, numbers, lists, or even entire objects. Once created, you can easily access and update these variables in subsequent steps of your application.
Input
- Value (Type: VARIABLE): The data or information you want to store in your new variable. If you leave this blank, the variable will be created without an initial value. Providing a value here also helps the platform understand the type of data your variable will hold (e.g., text, number, list, or object).
- Variable name (Type: VARIABLE, Required): This is the unique label you give to your new variable. You'll use this name to access or update the variable later in your application. This field cannot be left empty.
Output
- Variable name (Type: VARIABLE): This refers to the name of the variable that was successfully created and stored in your application's scope. It confirms the identifier you can now use to reference your new variable.
Execution Flow
Real-Life Examples
Example 1: Storing a User's Name
Imagine you have a form where users enter their name, and you want to store it for a personalized greeting.
- Inputs:
- Value: "Alice Johnson"
- Variable name: "currentUserName"
- Result: A new variable named
currentUserNameis created, holding the text "Alice Johnson". You can now usecurrentUserNamein other actions, like displaying a personalized greeting message.
Example 2: Initializing a Counter
You might need a variable to keep track of how many items a user has added to their cart.
- Inputs:
- Value: 0
- Variable name: "itemCount"
- Result: A new variable named
itemCountis created with an initial value of 0. This variable can later be updated (e.g., incremented) as items are added to a list.
Example 3: Creating an Empty List for Future Use
If you plan to collect multiple pieces of information, like a list of tasks, you can start with an empty list.
- Inputs:
- Value:
[](an empty list/array) - Variable name: "shoppingList"
- Value:
- Result: A new variable named
shoppingListis created as an empty list. You can then use other actions to add items to this list as needed.
Example 4: Storing a Complex Object
When dealing with structured data, like product details, you can store it as an object.
- Inputs:
- Value: ```json { "productName": "Laptop Pro", "price": 1200.00, "inStock": true }
* **Variable name**: "selectedProduct" - Result: A new variable named
selectedProductis created, holding a structured object with details about a product. You can access individual properties likeselectedProduct.productNamein subsequent steps.