Wiki

Scale Your Enterprise

User Tools

Site Tools


bw2:using_variables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
bw2:using_variables [2020/12/15 11:51]
akoehler [Example 3]
bw2:using_variables [2023/12/19 09:02] (current)
wgates
Line 5: Line 5:
 ====== What are Bizweaver Variables? ====== ====== 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**.+**“Variables”** are data values held in memory during the execution of a workflow. There are two types of variables in Bizweaver: **User Variables** and **Step Variables**.
  
-**“[[bw2:using_variables#Variables Tool|User Variables]]”** are defined by the user. These values can be defined in the Variables tool or they can be created using the **//[[bw2:vbscript_tool|VBScript]]//** tool.+**“[[bw2:using_variables#User Variable Example|User Variables]]”** are defined by the user. These values can be defined in the Variables tool or they can be created using the **//[[bw2:vbscript_tool|VBScript]]//** tool.
  
-**“[[bw2:using_variables#Step Variables|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 SQLCommand:Reader step.+**“[[bw2:using_variables#Step Variables|Step Variables]]”** are unique references created by the Bizweaver application. Most Bizweaver workflow tools make these variables as the step is executed. An example of this would be a reference to an output column from an SQLCommand: Reader step.
  
 Bizweaver variables are available to other workflow steps that follow the step where they are created. Bizweaver variables are available to other workflow steps that follow the step where they are created.
Line 15: Line 15:
 ====== Variables Tool ====== ====== Variables Tool ======
  
-The **Variables** tool can be used in two ways. First, it can be used to establish constant/static values 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.+The **Variables** tool can establish constant/static values to be used in the following workflow steps.
  
-{{  :bw:using_variables.png?600  |Variables}}+{{ :bw2:bizweavervartool1.png |}}
  
   * “Name” is the name of the variable.  This is how it is referenced in the workflow.   * “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.+  * "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.
  
 <WRAP center round tip 50%> <WRAP center round tip 50%>
Line 27: Line 27:
  
   * Click on the **X** at the right-end of a row to delete a variable.   * Click on the **X** at the right-end of a row to delete a variable.
-    * A variable cannot be deleted if it used in any workflow.+    * A variable cannot be deleted if it is used in any workflow.
  
 Following are examples of using variables. Following are examples of using variables.
Line 36: Line 36:
   * The __value__ field is blank because the value to be used will be sent in the API call to Bizweaver.   * The __value__ field is blank because the value to be used will be sent in the API call to Bizweaver.
  
-{{  :bw:using_variables2a.png?600  |}}+{{ :bw2:bizweavervartool2.png |}}
  
-The variable is then referenced in a subsequent SQL:Reader step. +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.+  * Any time a variable is referenced using <F4> in a SQL stepthe string must be enclosed in single quotes as shown.
  
-{{  :bw:using_variables2b.png?600  |}}+{{ :bw2:bizweavervartool3.png |}}
  
 ====Example 2===== ====Example 2=====
-In this example, variables are defined for login credentials that will be used at various points through the rest of the workflow.+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.+  * In this casethe __values__ are static.  They represent login information used to access the SAP HANA Service Layer API.
  
-{{  :bw:using_variables3a.png?600  |}}+{{ :bw2:bizweavervartool4.png |}}
  
 The variables are then referenced in a subsequent WebService2 tool step as shown. The variables are then referenced in a subsequent WebService2 tool step as shown.
  
-{{  :bw:using_variables3b.png?600  |}}+{{ :bw2:bizweavervartool5.png |}}
  
 ===== Calculations in Variables ===== ===== Calculations in Variables =====
  
-Arithmetic calculations can be applied to numeric variable during workflow execution. This functionality is introduced in Bizweaver version 2.1.0.+Arithmetic calculations can be applied to numeric variable during workflow execution. This functionality is introduced in Bizweaver version 2.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 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.+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===== ====Example 3=====
-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 SQLCommand step. for this example we will use a simple statement.+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 caseFor this examplewe will use a simple statement.
  
-{{  :bw:varimage3.png?576x69  }}+{{ :bw2:bizweavervartool6.png |}}
  
-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 “counter” variable is first defined in the “Variables_Init” step. In this casethe variable is named “ActionCount,” and the initial value is set to zero (0).
  
-{{  :bw:varimage4.png?303x171  }}+{{ :bw2:bizweavervartool7.png |}}
  
-The “SQLCommand_getData” step reads a list of data records. This list feeds into a loop.+The “SQLCommand” step reads a list of data records. This list feeds into a loop.
  
 <code> <code>
-Select  +SELECT 
-     (recordNumber-- This will be a record number from your table that you are using +     [recordNumber-- This will be a record number from your table that you are using 
-From +FROM 
-    (your table) -- table you are pulling the recordNumber from+    [yourTable] -- table you are pulling the recordNumber from
 </code> </code>
  
-The “counter” variable defined initially is incremented by 1 for each record that is passed into the loop.+The “counter” variable defined initially is incremented by 1 for each record passed into the loop.
  
-{{  :bw:varimage5.png?403x166  }}+{{ :bw2:bizweavervartool8.png |}}
  
-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.+In this processwe 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. +When all records have been read, the loop ends. At this pointthe “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.  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. 
  
-{{ :bw:evalfilewriterstep.png?nolink |}}+{{ :bw2:bizweavervartool9.png |}}
  
-This type of processing could be used in conjunction with a **//[[bw2:decision_tool#Decision Tool|Decision Tool]]//** such that processing would go in one direction or another based on the number of records found. 
  
 ====== Step Variables ====== ====== Step Variables ======
Line 100: Line 99:
 ===== Special Note for Step Variables and Loops ===== ===== 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.+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: The step named “SQL Command_getData” uses the SQL statement:
  
-<code sql>select +<code sql>SELECT CardCode,  
-t0.CardCode, t0.CardName, t0.CardType +   CardName,  
-from OCRD t0+   CardType 
 +FROM OCRD
 </code> </code>
  
 This produces a list of records that feeds into the loop “Loop_ProcessRecords.” The step variable created for “CardCode” is: This produces a list of records that feeds into the loop “Loop_ProcessRecords.” The step variable created for “CardCode” is:
  
-<code>WorkFlow(SQLCommand_getData).Get({FIELD_CardCode})</code>+<code>WorkFlow(SQLCommand).Get({FIELD_CardCode})</code>
  
 This step variable is used in the FileWriter_VariableTest step. This step variable is used in the FileWriter_VariableTest step.
Line 117: Line 117:
 The list contains the values C1, C2, and C3. 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 listor C1. Then, when the end of the loop processing is reached, the next record from the list is read.+The first time the file writer sees the step variablethe 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 statementor C2received from the loop processing. This cycle continues for each record read into the loop processing.+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.
  
 ====== Using Variables ====== ====== Using Variables ======
Line 125: Line 125:
 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. 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.
  
-{{  :bw:varimage6.png?455x253  }}+{{ :bw2:bizweavervarmanager1.png |}} 
  
   - Position the cursor in the field where the variable is needed.   - Position the cursor in the field where the variable is needed.
   - Press **F4**   - Press **F4**
-      - The ‘Choose Variable” dialog is presented+      - The ‘Choose Variable” flyout is opened
-  - Workflow steps prior to the current one are listed in the left-hand panel.+  - Workflow steps before the current one are listed in the right-hand panel.
       - Click on the appropriate step name.       - Click on the appropriate step name.
-  - Available variables for the selected step are displayed in the right-hand panel. +  - Available variables for the selected step are expanded for the step in the right-hand panel. 
-      - Select the desired variable and click [OK] to select the value into the target field. +      - Select the desired variable and double click.
 <WRAP left round tip> <WRAP left round tip>
-When variables are used, they have a very specific name structure, as shown in the **//[[bw:using_variables#Special Note for Step Variables and Loops|Using Variables with loops code snippet above]]//**. While it is possible to enter the variable name manually, this approach is not recommended. If this approach is taken make sure that the syntax of the variable is the same as it is in the step, this includes capitalization.+When variables are used, they have a particular name structure, as shown in the **//[[bw2:using_variables#Special Note for Step Variables and Loops|Using Variables with loops code snippet above]]//**. While it is possible to enter the variable name manually, this approach is not recommended. If this approach is takenmake sure that the variable'syntax is the same as it is in the step, including capitalization.
  
 </WRAP> </WRAP>
Line 142: Line 142:
 ====== Examples ====== ====== Examples ======
  
-Once a variable has been created it can be used in any subsequent workflow step.+Once a variable has been createdit can be used in any subsequent workflow step.
  
 ===== User Variable Example ===== ===== User Variable Example =====
  
-In a Bizweaver workflow a user can reference variables that are initiated earlier in the workflow using the variables tool.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.+In a Bizweaver workflowa user can reference variables initiated earlier in the workflow using the variables selector. In this examplea 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.
  
-The below workflow when processed will now only pull the CardType of "C" which is set in the "Variables_Init" step.+When processed, the below workflow will only pull the CardType of "C," set in the "Variables_Init" step.
  
-{{ :bw:uservariablesexamplewf.png?nolink |}}+{{ :bw2:bizweavervartool11.png |}}
  
-In the variables tool there is a **User Defined Variable ** of "UserVariable1"+In the variables toolthere is a **User-Defined Variable ** of "UserVariable1."
  
-{{ :bw:variablestoolscreen.png?569x110 |}}+{{ :bw2:bizweavervartool12.png |}}
  
-In the SQL tool step you can reference the **User Defined Variable** of "UserVariable1" by pressing [F4] in the SQL tool and navigating to the Variables option in the left menu and selecting the correct variable from the list of variables on the right menu.+In the SQL tool stepyou can reference the **User-Defined Variable** of "UserVariable1" by pressing [F4] in the SQL toolnavigating to the left menuand selecting the correct Variables option variable from the list of variables on the right menu.
  
-{{  :bw:varimage7.png?576x231  }}+{{ :bw2:bizweavervarmanager2.png |}}
  
 So, the SQL statement now uses the value ‘C’ in the variable “UserVariable1.” So, the SQL statement now uses the value ‘C’ in the variable “UserVariable1.”
  
-{{  :bw:varimage8.png?569x110  }}+{{ :bw2:bizweavervartool14.png |}}
  
 Since the variable value ‘C’ is a string (text), the variable name must be enclosed in single quotes as required by SQL. Since the variable value ‘C’ is a string (text), the variable name must be enclosed in single quotes as required by SQL.
Line 168: Line 168:
 ===== Step Variable Example ===== ===== Step Variable Example =====
  
-In this example we are writing the output of the SQL step to a file.+In this examplewe are writing the output of the SQL step to a file.
  
 Below is the workflow we are using for the example. Below is the workflow we are using for the example.
  
-{{ :bw:stepvariablesworkflow.png?nolink |}}+{{ :bw2:bizweavervartool17.png |}}
  
 Note the fields in the SQL statement that will be referenced later. Note the fields in the SQL statement that will be referenced later.
  
-{{ :bw:stepvariablessql.png?482x384 |}}+{{ :bw2:bizweavervartool14.png |}}
  
-Next when going to the file writer step you will press [F4] and select the variables from the SQL step.+Nextyou will press [F4] and select the SQL step variables when going to the file writer step.
  
-{{  :bw:varimage11.png?483x298  }}+{{ :bw2:bizweavervarmanager3.png |}}
  
 You can see each step variable in the "Body" section of the FileWriter Tool. You can see each step variable in the "Body" section of the FileWriter Tool.
  
-{{  :bw:varimage9.png?482x384  }}+{{ :bw2:bizweavervartool16.png |}} 
 + 
 +======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. 
 + 
 +{{ :bw2:bizweavervarmanager1.png |}} 
 + 
 +  * **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. 
 +    * **XML:** Selecting this will escape any reserved characters for an XML file. See the table below for more information. 
 +    * **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                                |\'|
  
  
  
bw2/using_variables.1608051077.txt.gz · Last modified: 2020/12/15 11:51 by akoehler