Skip to content

Variables

A variable is a named container where you store a piece of data to use later. Variables are how information travels between activities: one activity stores its result in a variable, and another activity reads it from there.

Without variables, each activity would be isolated. With variables, you can read an email, extract its subject, transform it and write it to an Excel file, passing the data from one step to the next.

variables panel at the bottom, with several variables, their type and initial value.

Variables are managed in the Variables tab of the bottom panel. Each variable has:

  • Name: how you refer to it in expressions.
  • Type: what kind of data it holds (text, number, table…). See Data types.
  • Initial value (optional): an expression with the value it starts with, for example 0, "pending" or newList().
  • Description (optional): what it is for, for whoever reads the playbook later.

Everything is edited right in the table, cell by cell.

  1. In the Variables tab, click + Add variable. A new row appears (variable1, of type string) with the cursor in the name.
  2. Type the name (see the rules below) and press Enter.
  3. Pick the type in the selector. It has a search box, and Composite type… builds types such as List<string> or Dictionary<string,object>.
  4. Optionally, type an initial value and a description.

variable creation row with name, type selector and initial value.

To delete a variable, use the trash icon at the end of its row or Delete. Right-click the row → Find references shows where it is used in the playbook.

RuleGoodBad
No spacesinvoiceNumberinvoice number
No symbolscustomerIdcustomerId#
Starts with a letter or _total, _temp1total
Not a C# reserved wordkindclass
Unique in the playbook (across variables and arguments)totaltwo total
Case-sensitivetotal ≠ Total—

If the name is not valid, the Designer tells you and keeps the previous one.

Activities that produce data have, at the end of the Properties panel, the Output section with the Save result in field. There you type the name of the variable where you want to store the result; on the right you see the type the activity returns. The field suggests the variables that already exist.

If the name you type is not declared yet, the field marks it as a new variable: press Ctrl+Shift+V to declare it with the output type.

Example: an HTTP GET activity that stores its result in response. In the following activities you can read:

response.StatusCode // 200
response.Ok // true
response.Body // response body

properties panel of Get Text with its "Save result in" output pointing to the firstParagraph variable.

After a run, the Preview (last run) section in Properties shows the value the activity produced, without leaving the Designer.

In any field with ƒx, type an expression that uses the variable:

email.Subject
"Hello " + customerName
total > 1000

Remember: fixed text goes in quotes ("Hello"); without quotes, the Designer reads it as a variable name.

Some activities declare variables for you. The most common one is For Each: it goes through a collection (items) and, on each pass, puts the current element in the variable you name in itemVariable. Optionally, indexVariable holds the position (starting at 0).

For Each items = emails itemVariable = email
└─ Body:
Log message = "Processing: " + email.Subject

Here email exists only inside the loop and changes on each pass. You don’t need to declare it in the panel: the For Each declares it.

  • The variables you declare belong to the playbook where you created them.
  • If you invoke another playbook with Invoke Playbook, they do not share variables. Instead:
    • You pass data to its inputs.
    • You receive data from its outputs.

This keeps each playbook isolated and reusable: an invoked playbook can’t accidentally “dirty” the caller’s variables.

When you pick the playbook in Invoke Playbook, the Properties panel shows one field per input it declares (with its default value, if any) and one field per output, where you type the variable that will receive the value.

I need…How
A counterAn int variable with initial value 0; on each pass, Set Variable with counter + 1
Accumulate in a listA List<string> variable with initial value new List<string>(); on each pass, the Add to List activity
A flag (yes/no)A boolean variable with initial value false; set it to true when something happens
Build a textA string variable; append text + "line" + nl()

Besides your own variables, every run exposes a set of read-only system variables with information about the current process. You don’t declare them (they are already available) and you read them in any expression with a $ prefix. Autocomplete lists them.

VariableContains
$system_playbook_nameThe name of the playbook currently running (it changes inside an invoked playbook).
$system_invoke_depthThe invocation depth: 0 in the main playbook, 1 in the first invoked one…
$system_playbook_started_atWhen this playbook started.
$system_run_started_atWhen the whole run started (the same across the invocation chain).
$system_host_nameThe name of the computer where it runs.
$system_os_userThe Windows user running the robot.
$system_execution_idThe identifier of this run (the same one you see in Zoan Cloud).
$system_process_nameThe name of the process being run.
$system_process_versionThe version of the published process.
$system_process_idThe process identifier.
$system_environment_idThe identifier of the environment where it runs.
$system_entryThe entry playbook (the one that starts the run).
$system_instance_idThe flow case that launched this run.
$system_step_idThe flow step that launched this run.
$system_idempotency_keyThe step’s idempotency key: the same across its automatic retries. Use it so an external system doesn’t repeat work; see Robots inside a flow.
$system_business_keyThe business key of the flow case (for example, the invoice number).

The last four only have a value when a flow step launches the run; otherwise they are empty.

For example, to log which process and run produced some data, or how long the run has taken:

Log message = "Processed by " + $system_process_name + " v" + $system_process_version + " (exec " + $system_execution_id + ")"
Log message = "Seconds elapsed: " + (now() - $system_run_started_at).TotalSeconds
SymptomCauseSolution
”The name ‘x’ does not exist in the current context”You used a variable that is not declared, or the name doesn’t matchDeclare it (Ctrl+Shift+V from the field) or fix the name: Total and total are different
”Invalid variable to write”The output points to an undeclared variable or a system variableDeclare the variable or pick another name
The value “isn’t saved” between activitiesThe activity had no Save result in setType the variable name in the Output section
The name is saved instead of the valueYou put the variable name in quotesRemove the quotes: customer, not "customer"
  • Data types: what you can do with each type of variable.
  • Expressions: read and transform variables.
  • Debugging: inspect your variables’ values while running.