The Set Variable task allows you to programmatically update the value of a predefined Variable within Zeroplat’s Event Designer. Variables are a powerful mechanism to store and reuse temporary data (primitives or objects) across pages, events, and tasks.
This task works in combination with variables created in the Explorer panel.
Purpose
- Dynamically assign values to a variable during an event.
- Store values from inputs, queries, or other tasks for later use.
- Pass intermediate state between multiple actions in a workflow.
Creating a Variable
- Open the Explorer panel.
- Click New Item → Variable.
- Assign a name (e.g.,
variable1
). - Optionally, define an Initial Value (e.g.,
{{ Button1.disabled }}
). - The variable will now appear in Explorer and can be referenced inside tasks as
{{ variable1.value }}
.
Anatomy of the Set Variable Task
- Step name
- The label for the task in the event flow.
- Example:
Set variable
.
- Variable name*
- Dropdown to select which variable you want to update.
- Example:
variable1
.
- Set value
- The new value to assign to the selected variable.
- Supports primitives (string, number, boolean), object literals, arrays, or dynamic bindings.
- Example:
{{ Input1.value }}
- Or an object:
{ id: Table1.selectedRow.id, name: Table1.selectedRow.name }
How It Works
- A variable (
variable1
) is defined in Explorer. - The Set Variable task runs inside an event (e.g., Button click).
- The value in Set value is assigned to the variable.
- Anywhere else in the page, you can access the updated value via
{{ variable1.value }}
.
Example 1: Assigning Input Value
- Variable:
variable1
- Set value:
{{ Input1.value }}
Usage elsewhere:
Hello, {{ variable1.value }}
Example 2: Storing Query Results
- Variable:
customerData
- Set value:
{{ query1.data }}
Usage elsewhere:
{{ customerData.value[0].name }}
Example 3: Using Variables for Conditional Logic
- Set
isFormValid
totrue
after validation. - Later, use it in a conditional flow:
{{ isFormValid ? "Proceed" : "Show error" }}
Best Practices
- Use descriptive variable names → e.g.,
selectedCustomer
,isFormValid
. - Initialize complex variables (objects/arrays) in Explorer with
{}
or[]
. - Avoid overwriting structure unintentionally → keep response data formats consistent.
- Combine with JS Queries/Transformers for more advanced computed state.
FAQ
Q: Can variables persist across pages?
- No. Variables are page-scoped. For global data, consider APIs, workflows, or persistent storage.
Q: Can I bind a variable directly to a component?
- Yes. Components can read/write variable values by using
{{ variableName }}
as their property.
Q: Can I reset a variable?
- Yes. Use
Set Variable
with{}
ornull
to clear it.
👉 In summary: Set Variable is the glue for temporary state in Zeroplat. You define variables in Explorer, update them dynamically via Set Variable tasks, and consume them anywhere in your page through bindings. This enables dynamic, data-driven interactions without external storage.