Shared Variables

Overview


AutoMate variables play an important role in the creation of intelligent, nimble automated processes because they enable developers to add flexibility to a task. Rather than entering data directly into a task, a developer can use variables as a means to provide temporary storage for dynamic data in which to call upon during execution of the task. This makes it possible for the same task to process different sets of data each time it executes.

In AutoMate BPA Server 9, variables take on a much larger role because they have the ability to become “Shared Variables”. Shared variables are essentially variables that are accessible throughout an entire workflow. They are identical to normal variables in that their value can be interpreted, set or changed during task execution. But unlike normal variables that are created and shared within a single task, the value of a shared variable can be read by other workflow objects or its contents modified by other tasks that reside in the same workflow. Once a Shared Variable is created, its contents can be called upon by other workflow objects (i.e. tasks, evaluation objects, etc.) at runtime by enclosing the variable name with percentage (%) signs.

Shared variables are declared at the workflow level. This informs the workflow that the contents of the variable can be shared between all objects in the workflow. For example, a workflow’s path includes several tasks which are named Task1, Task2, Task3 and Task4. If a variable created in Task1 running on Agent A, is declared by the workflow as a shared variable, (by entering the variable name in the Shared Variables tab), that variable and its value can be accessed and/or modified by Task2, 3 or 4 running on any Agent as long as those tasks are executed within the same workflow.

Creating & Managing Shared Variables


In order for a variable to be declared as a shared variable, it must be added to the Shared Variables tab of the Workflow Designer.

To add a shared variable to a workflow:

  1. From the Workflow Designer, select the Shared Variables tab.

  2. Right click anywhere inside the Shared Variables section. This will display a pop-up menu. Select the Add Variable option as shown below, circled in red.

  1. A dialog titled Workflow Variable appears, as shown below.

  2. Enter required data and click Ok to save the settings and close the dialog box.

To delete an existing shared variable:

  1. From the Shared Variables tab, right-click the variable to delete.

  2. Select Delete Variable from the context menu that appears.

  3. To delete all shared variables, select Delete All Variables.

To edit an existing shared variable:

  1. From the Shared Variables tab, right-click the variable to edit.

  2. Select Edit Variable from the context menu that appears.

  3. The Workflow Variable dialog appears.

  4. Make the appropriate modifications and click OK to save changes.

To rename an existing shared variable:

  1. From the Shared Variables tab, right-click the variable to rename.

  2. Select Rename Variable from the context menu that appears.

  3. Enter a new name for the variable. Make sure that associated workflows or tasks point to the new variable name. otherwise an error will occur during runtime.

Parameters


Shared Variables are used as a storage mechanism to store and share data during the execution of a workflow. The Workflow 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 Tab Properties

Property

Description

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 Tab Properties

Property

Description

Variable Type

Causes the variable to assume a specific type. The available options are:

  • Auto - 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 - Variables 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 - 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 thrown.

Passing variables To/From Sub-workflows

These properties dictate how the shared variable should react when passed to from the parent workflow to a sub-workflow and vise 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 variable is set to. If disabled, the value of the shared variable is only available to the parent workflow and will not be passed to the sub-workflow.

  • Pass the value from this variable to the Parent Workflow when this workflow finishes - If enabled, the value of a shared variable encompassed in the embedded or sub- workflow is allowed to propagate back to the parent workflow upon the embedded workflow’s completion. If disabled, the shared variable’s value will not be passed to the parent workflow.

 

NOTE:

  • Only shared variables with the same name are passed between parent and embedded workflows and vice versa (when the settings permit).

  • Remember not to use percentage signs when specifying the name of a variable to populate, percentage signs are only needed to get data "out".

See Also


About Variables | Shared Arrays | Shared Datasets | Workflow Designer | Multi-machine Workflows