Wiki

Scale Your Enterprise

User Tools

Site Tools

mbstring extension must be loaded in order to run mPDF

bw:using_variables

This is an old revision of the document!


Introduction (Using Variables)

This document describes the use of variables in a Bizweaver workflow.

General Workflow Step Information

  • Each workflow step must have a unique name.
    • The application will assign a default name, but we recommend that you change the name to something that helps you understand the purpose of the step as it is used in other steps.
  • The name cannot have spaces or special characters other than and underscore (_)
  • Press <F4> to find and use values from previous workflow steps.

What are Bizweaver 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 SQLCommand:Reader step.

Bizweaver variables are available to other workflow steps that follow the step where they are created.

Variables Tool

The Variables tool can be used in two ways. First, it can be used to establish constants to be used in following workflow steps. Second, it can be used to capture values from previous workflow steps. The second option is not often used since values from previous steps can be referenced directly. Following is an example of these options.

Variables

  • “Var1” is the name of the variable. the letter “C”, that can be used is subsequent workflow steps.
  • Click on the gray area at the end of a row (as noted in the red box in the image above) to open an editing window for the “Value” field. This functionality is introduced in Bizweaver v2.2.

New in v2.4

  • Click on the red X to delete a variable.

Calculations in Variables

Arithmetic calculations can be applied to numeric variable during a workflow execution. This functionality is introduced in Bizweaver v2.1.0.

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.

A common 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.

Following is a simple example of how a “counter” calculation is defined. In this case we want to know how many records were passed into a loop from a SQLCommand step.

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_getData” step reads a list of data records. This list feeds into a loop.

The “counter” variable defined initially is incremented by 1 for each record that is 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.

This type of processing could be used in conjunction with a Decision such that processing would go in one direction or another based on the number of records found.

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 creates the variable feeds a Bizweaver loop, the value for the same variable 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
t0.CardCode, t0.CardName, t0.CardType
FROM OCRD t0

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

WorkFlow(SQLCommand_getData).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 step 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.

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

Using Variables

The following image illustrates how variables are selected. This process is used in all instances where some variable needs to be referenced. The list of available workflow steps will get larger as you progress through additional steps in the workflow.

  1. Position the cursor in the field where the variable is needed.
  2. Press F4
    1. The ‘Choose Variable” dialog is presented.
  3. Workflow steps prior to the current one are listed in the left-hand panel.
    1. Click on the appropriate step name.
  4. Available variables for the selected step are displayed in the right-hand panel.
    1. Select the desired variable and click [OK] to select the value into the target field.

When variables are used, they have a very specific name structure, as shown in the “TimeStamp” example above. While it is possible to enter the variable name manually, this approach is not recommended.

Examples

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

User Variable Example

In the step marked “3” in the illustration above, a SQL statement is being used to report 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.

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 the step marked “4” in the illustration above we are writing the output of the SQL step to a file.

In this step, we make use of both Step and User variable type.

To make the file name unique each time it is created, we use the “time stamp” user variable created by the VBScript step. As noted earlier, we can use either the output name from the VBScript step, or the value created in the Variables step. For this example, the value from the VBScript step is used.

C:\Shared\Bizweaver\DataOut\Filewriter_VariablesTest_WorkFlow(VBScript).Get(TimeValue).txt

The values in the body section of the file (the actual data records) are step variables that come from the previous SQL Command step (3).

bw/using_variables.1568205884.txt.gz · Last modified: 2019/09/11 08:44 by runger