Wiki

Scale Your Enterprise

User Tools

Site Tools


bizweaver:wf_var

This is an old revision of the document!


Workflow Variables

Variables are data values that are held in memory during the execution of a workflow. There are two types of variables in Bizweaver: User Variables and Step Variables.

User Variables are defined by the user. These values can be defined in the Variables tool or they can be created using the VBScript tool.

Step Variables are special references created by the Bizweaver application. Most Bizweaver workflow tools create these variables as the step is executed. An example of this would be a reference to an output column from a SQL/HANA Tool or File Reader step. Bizweaver variables are available to other workflow steps that follow the step where they are created.

To access these variables while in any workflow tool, click the Variables icon on the toolbar. This will display the Variable Explorer window. Workflow steps will be displayed in the order they are in the workflow. Workflow variables will be displayed under the tool name in alphabetical order.

  • Use the refresh icon to update the variable in the Variable Explorer as changes are made in the workflow design
  • Use drag & drop to place variable in your tool configuration.

Variables Tool

The Variables tool can establish constant/static values to be used in the following workflow steps.

  • “Name” is the name of the variable. This is how it is referenced in the workflow.
  • “Value” is the actual value represented by a variable. Click on the gray area near the end of a row to open an editing window for the “Value” field.
  • A variable cannot be deleted if it is used in any workflow.

Following are examples of using variables.

Example 1

In this example, the workflow is being called via the Bizweaver API. The name expected to come from the calling application is expected to be “vgoRecNum”.

  • The name is case sensitive.
  • The value field is blank because the value to be used will be sent in the API call to Bizweaver.

The variable is then referenced in a subsequent SQL: Reader step.

  • Any time a variable is referenced using <F4> in a SQL step, the string must be enclosed in single quotes as shown.

Example 2

In this example, variables are defined for login credentials used at various points throughout the workflow.

  • In this case, the values are static. They represent login information used to access the SAP HANA Service Layer API.

The variables are then referenced in a subsequent WebService2 tool step as shown.

Calculations in Variables

Arithmetic calculations can be applied to a numeric variable during workflow execution.

A calculation using a variable is done by using the “EVAL{}” function in the “Value” of the variable. The calculation can be done against both user and step variables. The calculation is placed within the braces {} as shown in the examples.

Everyday use of this functionality is to maintain a counter to control processing or document processing. The calculation will typically be placed inside of a loop construct.

Example 3

Following is a simple example of how a “counter” calculation is defined. We want to know how many records were passed into a loop from an SQLCommand step in this case. For this example, we will use a simple statement.

The “counter” variable is first defined in the “Variables_Init” step. In this case, the variable is named “ActionCount,” and the initial value is set to zero (0).

The “SQLCommand” step reads a list of data records. This list feeds into a loop.

SELECT
     [recordNumber] -- This will be a record number from your table that you are using
FROM
    [yourTable] -- table you are pulling the recordNumber from

The “counter” variable defined initially is incremented by 1 for each record passed into the loop.

In this process, we are taking whatever value is in “ActionCount” and adding 1 to it. The initial value was zero, so when the first record is processed, “ActionCount” = 0 + 1, so now “ActionCount” = 1. This process continues for each record that is passed into the loop.

When all records have been read, the loop ends. At this point, the “ActionCount” variable will contain the number of records that were passed into the loop.

The final step of the workflow writes out a file with the record count information. Below is the file writer step information to write the information to a text file.

Step Variables

Step variables are created by Bizweaver and do not require any user action. These variables are available as soon as a step has been executed.

Special Note for Step Variables and Loops

As noted, step variables are created when a step executes. When the step that makes the variable feeds a Bizweaver loop, the same variable's value will change for each loop cycle. Following is an example of this using the workflow shown above. For this example, we will focus on the “CardCode” value.

The step named “SQL Command_getData” uses the SQL statement:

SELECT CardCode, 
   CardName, 
   CardType
FROM OCRD

This produces a list of records that feeds into the loop “Loop_ProcessRecords.” The step variable created for “CardCode” is:

WorkFlow(SQLCommand).Get({FIELD_CardCode})

This step variable is used in the FileWriter_VariableTest step.

The list contains the values C1, C2, and C3.

The first time the file writer sees the step variable, the value will be the first record in the list or C1. Then, when the end of the loop processing is reached, the next record from the list is read.

When the file writer step sees the same step variable, the next record will be returned from the SQL select statement or C2 received from the loop processing. This cycle continues for each record read into the loop processing.

Examples

Once a variable has been created, it can be used in any subsequent workflow step.

User Variable Example

In a Bizweaver workflow, a user can reference variables initiated earlier in the workflow using the variables selector. In this example, a SQL statement is being used to pull information from the database. We want to limit the data based on a certain value. In this example, a value from the “Variables” step is used.

When processed, the below workflow will only pull the CardType of “C,” set in the “Variables_Init” step.

In the variables tool, there is a User-Defined Variable of “UserVariable1.”

In the SQL tool step, you can reference the User-Defined Variable of “UserVariable1” by pressing [F4] in the SQL tool, navigating to the left menu, and selecting the correct Variables option variable from the list of variables on the right menu.

So, the SQL statement now uses the value ‘C’ in the variable “UserVariable1.”

Since the variable value ‘C’ is a string (text), the variable name must be enclosed in single quotes as required by SQL.

Step Variable Example

In this example, we are writing the output of the SQL step to a file.

Below is the workflow we are using for the example.

Note the fields in the SQL statement that will be referenced later.

Next, you will press [F4] and select the SQL step variables when going to the file writer step.

You can see each step variable in the “Body” section of the FileWriter Tool.

String Manipulation

Starting in Bizweaver 2.7.2, the functionality to modify variables was introduced. This allows a user to manipulate all variables that are inserted in a specific step.

  • Escape: Selecting this checkbox will enable or disable the escaping functionality.
    • Only one of these can be selected at once, and they only apply in the step in which they are enabled.
    • JSON: Selecting this will escape reserved characters for a JSON file. See the table below for more information.
      • This will generally be used in a Databuilder step
    • XML: Selecting this will escape any reserved characters for an XML file. See the table below for more information.
      • This will generally be used in a Databuilder step
    • SQL: Selecting this will escape reserved characters for SQL Server see table below for more information
  • Replace empty values with NULL: This will take any empty strings or blanks ex '' and replace it with NULL
    • This works independently of the Escape functions.
JSON Reserved Character Explanation Escaped Value
Backspace A backspace in any text in a string \b
Form feed Advanced to the next page \f
Newline A new line in a string \n
Carriage return A carriage return in a string \r
Tab A tab in a string \t
A double quote \”
\ A backslash \\
XML Reserved Character Explanation Escaped Value
< Less than sign &lt;
> Greater than sign &gt;
& Ampersand &amp;
Double quote &quot;
' Single quote &apos;
SQL Reserved Character Explanation Escaped Value
' Single quote \'

Home

bizweaver/wf_var.1727199519.txt.gz · Last modified: 2024/09/24 13:38 by dlee