Shared Variables
Overview
In Automate, variables take
on a much larger role with their ability to be "shared" amongst
other objects within a given workflow. Similar to a variable used inside
a task, a shared variable is used as a storage mechanism to store and
share dynamic data during execution. However, unlike a task variable that's
created and accessible only within the task level, a shared variable is
created and declared at the workflow level, thus, its value can be recognized
by other workflow objects (for example, result arrow, evaluation object, sub-workflow,
etc.) and its contents can be set or modified within any task that exists
in that workflow.
Once a variable is created at the workflow
level, it is declared a shared variable making it accessible by any object
contained in that workflow as long as its name is enclosed with percentage
signs (for example, %variableName%). Unlike a normal variable, a shared variable
can be accessed within any task step without the use of a Create
variable activity. In addition, a shared variable can be passed
from a parent workflow to a child workflow (or sub-workflow) and vice
versa.
The ability to define shared variables
within a workflow provides an abundance of new functionality. Processes
that were once limited to one task running on one computer can now be
fully integrated into a multi-machine environment.
NOTE:
- Shared variables cannot reference a variable in the same task as its evaluation takes place at step 0.
- Shared variables can reference a constant or variable already set by another task and access it as the result of a subtask call.
In
order for a variable to be declared as "shared", it must
be added to the Variables
tab located in the Output/Shared
Objects panel of the Workflow Designer. The variable will auto-detect whether it contains
a number or text. The variable will adapt to the proper type
when possible depending on the operation being performed.
To create a shared variable
-
From
the Workflow Designer, select the Variables
tab.
-
Right-
click anywhere inside the panel, and then select Add
Variable.
-
Enter
the desired settings under the General
and Advanced tabs, and then select
OK.
Variable parameters
The Variable
dialog described above is used to enter the name of the shared variable,
its initial value (if required) and other parameters that dictate
its behavior. The available parameters are described below.
General
Name |
The name of
the variable that should be shared throughout the workflow. |
Initial
Value |
An optional
value that the variable should be set to initially. As with
all parameters, this value may be literal or an expression
(if surrounded by percent % signs). |
Description |
An optional
text description that describes the purpose of the shared
variable. |
Advanced
Variable
type |
Causes the
variable to assume a specific type. The available options
are:- Auto (default) - The variable will auto-detect whether
it is populated with a number or text. The variable will
adapt to the proper type when possible depending on the
operation being performed.
- Text
- The variable will always be treated as text (by default)
regardless of its contents. If an operation is attempted
that is only valid for numbers, an error will be generated.
- Number
- The variable will always be treated as a number regardless
of it's contents. If an operation is attempted that is
only valid for numbers, an error will be generated.
|
Passing
variables to/from sub-workflows |
Dictates how
the shared variable should react when being passed from the
parent workflow to a sub-workflow and vice versa. The available
options are:- Pass
the value from the parent workflow to this variable when
this workflow starts, overriding this variable's initial
value - If enabled, the value of the shared variable
that resides in the parent workflow is allowed to be passed
to any embedded workflow (or sub-workflow). The value
passed from the parent workflow will override any initial
value that the sub-workflow is set to. If disabled, the
value of the shared variable is only available to the
parent workflow and will not be passed to any sub-workflow
(disabled by default).
- Pass
the value from this variable to the parent workflow when
this workflow finishes - If enabled, the value
of a shared variable that resides in the sub-workflow
is allowed to propagate back to the parent workflow upon
completion. If disabled, the shared variable’s value will
not be passed to the parent workflow (disabled by
default).
NOTE:
Only shared variables with the same name are passed between
parent and sub-workflows and vice versa (when the settings
permit). |
The Workflow Designer's Variables
tab is ideal in managing and debugging shared variables. Here, you
can add, edit, rename or delete shared variables and examine
variable content, particularly its initial and current value, during
runtime without inserting additional steps to output the values. Furthermore,
you can insert breakpoints at certain points in your workflow to halt
execution in order to view the contents of a shared variable to determine
if the current value has been properly set or modified by a specific
task.
To delete a shared variable
From the Workflow Designer
Variables tab, right-click the variable to delete, select Delete Variable (if deleting
a single variable) or Delete Selected Variables (if
deleting multiple variables). To select
more than one variable, hold down CTRL during selection.
NOTE: Make sure that any reference
of deleted shared variables are removed from sub-workflows
or tasks, otherwise an error will occur during execution.
To edit a shared variable
-
From the Workflow Designer
Variables tab, right-click the variable to edit, and then select Edit Variable.
-
Make the appropriate modifications. and then select OK to save changes.
To rename a shared variable
-
From the Workflow Designer
Variables tab, right-click the variable to rename, and then select Rename
Variable.
-
Enter a new name for the variable.
The Variables tab generates
information divided into seven columns:
Name |
The name of the shared variable. |
Type |
The type of shared variable as set in the
variable's properties (Auto, Text, or Number). |
Initial
|
Displays the initial value of the shared
variable as set in the variable's properties. If no value
was set, this field is blank. |
Current
|
Displays the current value of the shared
variable during workflow execution. The value is updated after
each workflow object executes. |
Description |
A description of the shared variable as
set in the variable's properties. The description does not
affect variable performance at runtime. |
Right-click a shared variable or an empty region inside the Variables tab to view the following
menu items:
Add
Variable |
Adds a shared variable to the current workflow. |
Edit
Variable |
Opens the properties dialog of the shared
variable, allowing you to modify its contents. |
Copy |
Copies
the shared variable and its properties. |
Paste |
Pastes
the shared variable and its properties. |
Rename
Variable |
Renames a shared variable. |
Delete
Variable |
Deletes the selected shared variable. |
Delete
Selected Variables |
Deletes the selected shared variables.
To select more than one variable, hold down CTRL during selection. |