Shared Variables

In BPA Server, 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 (e.g., 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 (e.g., %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.

Declaring shared variables

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.

To create a shared variable:

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

  2. Right click anywhere inside the panel to display the context menu. Select theAdd Variableoption (as shown below, circled in red).

  3. A dialog titled Variable appears, as shown below.

  4. Enter the desired settings under the General and Advanced tab and click OK to save changes and close the dialog box.

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 Parameters

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 Parameters

Property

Description

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).

Managing Shared Variables

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 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:

  1. From the WFD Variables tab, right-click the variable to delete. To select more than one variable, hold down CTRL during selection then right-click the highlighted variables.

  2. From the context menu that appears, select Delete Variable (if deleting a single variable) or Delete Selected Variables (if deleting multiple variables).

  3. A prompt appears confirming deletion. Click YES to complete the operation.

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:

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

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

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

To rename a shared variable:

  1. From the WFD 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.

Parameters

The Variables tab generates information divided into seven columns:

Column Header

Description

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 Value

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 Value

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.

Access

Public  - The variable or function is visible and accessible to external tasks.

Private  - The variable or function is not visible or accessible to external tasks.

Scope

Local  - Specifies that the variable is local to the current context or scope. Usually, this means the procedure or function you are currently executing.

Task  - Specifies that the variable is a task variable that is considered global to the entire task.

Context Menu

Right-click a shared variable or an empty region inside the Variables tab to view the following menu items.

Item

Description

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.