To create a variable, just click the Add Variable button from the Variables section in the Ruleset editor and define its value.
Choose from the following types:
- String
- Number
- Boolean
- Object
- Date-Time
- List
- Duration
- Storage Node
- Binary
String-type Variables
String-type variables can be used to populate rule properties with character data that does not appear in local data files or incoming documents.
-
Click the Add Variable button to produce the Create a New Variable window.
- In the Name field, type what you'd like to call the variable.
- Select String from the Type drop-down.
- If you want to hard-code a value, type it in the Value field.
- If you wish to set an empty string (removing some characters is a common use case), then select the Initialize as empty string checkbox.
- (Version 1 Rulesets only) If you want to limit how long the data string can be, select the Set String Constraints check box. Type the maximum length in the Length field.
- Click OK to complete this task.
Number Variables
Number-type variables can be used to populate rule properties with numeric data that does not appear in local data files or incoming documents.
-
Click the Add Variable button to produce the Create a New Variable window.
- In the Name field, type what you'd like to call the variable.
- Select Number from the Type drop-down.
- If you want to hard-code a value, type it in the Value field.
- If you want to limit the number of digits in the number, select the Set Numeric Constraints check box. Type the maximum length in the Total Digits field and how many decimal places should appear in the Decimal Precision field. This works in version 1 Rulesets only.
- Click OK to complete this task.
Boolean Variables
Boolean-type variables can be created with an initial true or false value, or to be populated later with a true or false value from a rule. Boolean-type variables are used mainly when customizing a Rule's condition.
-
Click the Add Variable button to produce the Create a New Variable window.
- Click OK to complete this task.
Object Variables
Object-type variables can be used to populate rule properties with data that does not appear in local data files or incoming documents. Use an object-type variable when you do not know what type of data (string, number, etc.) will populate the variable.
-
Click the Add Variable button to produce the Create a New Variable window.
- In the Name field, type what you'd like to call the variable.
- Select Object from the Type drop-down.
- Click OK to complete this task.
DateTime Variables
The DateTime variable type holds the representation of a date and/or time in the format of the number of milliseconds since January 1, 1970. This variable type is currently supported in the new transformation engine only.
You can safely manipulate date-time values in your data without the need for manual editing or custom rules to do so.
The Move rule (version 2) automatically converts the date into DateTime format (for EDI and Database).
In conjunction with this variable type, several Actions are available in the Ruleset.
Creating a DateTime Variable
- Click Add Variable.
- Type the name you wish to give the variable.
- Select DateTime from the Type drop-down.
- Click OK to complete this task.
Result: The new variable now appears (identified as ) as an option in the Variables pane.
Example
This simple example shows how you might use a DateTime variable with several Actions. We will use the DateTime variable to set an initial value for a specific date - 12192000. We will then take that variable and add one day using another action. Finally we will format and write the output.
- CreateDateTimeFromString
- AddDateTimeWithFields
- FormatDateTime
But first we must create the DateTime variable from the Ruleset editor.
This variable, named "DT", is now available for use from the Variables pane.
Action: CreateDateTimeFromString
- Define Inputs (12192000)
- Define the pattern (mmddyyyy)
- Use "DT" as output.
Action: AddDateTimeWithFIelds
- Define inputs, using "DT"
- For DayOfMonth, define as “1”. For this example, we are simply adding one day to the initial DateTime.
- Again, use "DT" as output.
Action: FormatDateTime
- Define inputs, using "DT".
- Define the pattern. (mmddyyyy)
- Write the string out to target.
Now that we have our three Action used as Rule in the Ruleset, we can run the transformation and test the output.
Result: Initial source DateTime of 12192000 is written to target (Field 1) as 12202000.
List Variables
The List variable can be used to store groups of Boolean, String, or Numeric data types within a Ruleset.
- Selectively extract values for use in rules in the Ruleset.
- Called as a looping construct in a Composite Rule.
In conjunction with this variable type, several List-related Actions are available.
Creating a List Variable
- Click Add Variable.
- Type the name you wish to give the variable.
- Select List from the Type drop-down.
- Select the Element Type. Choices are Boolean, String, and Number.
- Click OK to complete this task.
Result: The new variable now appears as an option in the Variables pane.
Example
This simple example shows how you might use several of the Actions with the List variable type.
The first Rule uses the CreateList Action, which uses the List-type variable that we already created – ListField.
The next Rule - a For Each Composite Rule - shows that it contains five child rules. All but one are Move rules; the second Rule down is another Collection Rule – ListAdd, which in this case will add an element (“Field 2”) to the “ListField” list.
Another Composite Rule (For each ListField….) creates a new record for each element in the List. In this case we only have one element, “Field 2”. The output below shows how these rules could execute.
While this example may be simple, it demonstrates the two use cases noted above.
Duration Variables
The Duration Ruleset variable type can be used to calculate the time between two DateTime variable types, or used to increment/decrement a DateTime value. You can safely manipulate duration values in your data without the need for manual editing or custom rules. Several Actions support this type.
Creating a Duration Variable
- Click Add Variable.
- Type the name you wish to give the variable.
- Select Duration from the Type drop-down.
- Click OK to complete this task.
Result: The new variable (shown as ) now appears as an option in the Variables pane.
Example
This Ruleset example shows four Composite Rules using the Duration variable type and several supporting Actions.
Each Composite Rule works with a common DateTime variable having these values.
Composite Rule #1
Composite Rule #2
Composite Rule #3
Composite Rule #4
StorageNode Variables
The StorageNode variable type holds the representation of data that may be defined by a Schema.
This variable type can now be used as a Source and/or Target for a Ruleset Method, which can now transform data that is created/retrieved within the Ruleset; data that may have a Schema which differs from the Ruleset’s Source/Target. This allows you to transform more data without having to build multiple Rulesets to do so.
Creating a StorageNode Variable
- Click Add Variable.
- Type the name you wish to give the variable.
- Select StorageNode from the Type drop-down.
- Click OK to complete this task.
Result: The new variable now appears (identified as ) as an option in the Variables pane.
Comments
0 comments
Please sign in to leave a comment.