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:
-
From the Workflow Designer, select the Variables tab.
-
Right click anywhere inside the panel to display the context menu. Select theAdd Variableoption (as shown below, circled in red).
-
A dialog titled Variable appears, as shown below.
-
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:
|
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:
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:
-
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.
-
From the context menu that appears, select Delete Variable (if deleting a single variable) or Delete Selected Variables (if deleting multiple variables).
-
A prompt appears confirming deletion. Click YES to complete the operation.
To edit a shared variable:
-
From the WFD Variables tab, right-click the variable to edit.
-
Select Edit Variable from the context menu that appears.
-
Make the appropriate modifications and click OK to save changes.
To rename a shared variable:
-
From the WFD Variables tab, right-click the variable to rename.
-
Select Rename Variable from the context menu that appears.
-
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. |