Configure an input column with JavaScript
This topic describes how to configure an input column to use JavaScript as input in the decision table. This is useful when you want to use custom code as input in the decision table.
To configure an input column with JavaScript:
-
On the Decision Table tab, in the Input column, click Add Input Column.
-
In the Add Input Column dialog, click Script.
-
In the Name Column field, enter an intuitive name. The name you enter displays as a column header.
-
Click Add. The JavaScript editor displays.
-
On the Settings tab, in the Output Reference field, enter an output reference for the input. This enables you to select the output of the decision table as input in another decision. You must apply the following naming conventions:
-
Do not use hyphens or spaces.
-
The first character must either be an ASCII letter (either uppercase or lowercase), a letter that complies with Unicode variable naming conventions, or an underscore (_) character.
-
Do not use a number as your first character.
-
Subsequent characters must be letters, numbers, or underscores (_).
-
Do not use a reserved word. A reserved word is a keyword that is reserved by JavaScript functions or other uses that cannot be used as identifiers such as variable names, function names, and class names.
-
-
In the Type drop-down list, click the format type of the variable that you want to use as input in the decision table. This is the format type of the variable that is returned from the JavaScript and used as an input in the decision table:
-
String - a text value.
-
Boolean - a binary value that can either be true or false.
-
Integer - a number value.
-
Long - an integer that is longer than the size of the standard Integer type. This is useful for large numbers.
-
Date - represents a date value.
-
List - returns an array for use in a single variable.
-
Map - returns the entire object for the next decision to use.
ImportantIf you select List or Map as the format type, you won’t be able to use the output of that decision table as input into another decision table.
-
-
To copy and paste data model attributes and paths to use as dynamic data in JavaScript, click the Data tab. To see the data model, you must search for a guest by email address, or click Quick Select Customer or Quick Select Visitor. For example, if you want to use segment membership as dynamic data, search for a guest who is a member of the segment.
-
Enter the JavaScript in the JavaScript editor and click the gear icon to use the following features as required:
-
Night mode - click this link to change the background of the Editor to black. To toggle back to a white background, click the Day mode link.
-
Upload - click this link to upload JavaScript as a .txt file from your local drive.
-
Download - click this link to download JavaScript as a .txt file from your local drive. You might want to do this if you want to reuse the JavaScript in another Decision Model.
-
Copy all - click this link to copy all the JavaScript to your clipboard.
-
-
Click Save. You return to the Decision Table tab.
-
To continue creating your decision table you can configure an output column.