Create a decision template
A decision template is a programmable decision that you configure and make available to other users on the decision palette.
You can optionally create a form for the decision template. When the marketer adds the decision template to the decision canvas, the form displays for the marketer to complete. This enables the marketer to configure decision logic without having to write or edit code.
When you create a decision template, you can use any real-time data made available by a service known as the guest context service.
To reference the output of the decision in other decisions, you must create an output reference. An output reference is a name that you save to the decision template. This makes it easy to pass the result of a decision as input in another decision. For example, you can enable a user to pass the result of the Retrieve Upcoming Orders Decision Template to a decision table that determines the next best offer.
Team members with a User, Developer, or Admin role in Sitecore Cloud Portal can create a decision template.
To create a decision template:
-
On the navigation menu, click Developer Center > Decision templates.
-
On the Decision Templates page, click Create.
-
In the Name your Template field, enter an intuitive name for the decision template. As you type, the name of the template displays in the ID field.
-
Click Create. The template editor displays for you to customize using JavaScript.
NoteSitecore CDP automatically populates the name of the decision template in the output reference field. The user will see the name of the output reference display as helper text when configuring it as an input in another decision.
-
Click the Settings tab in the right name to edit the name that displays in the Output Reference field. Use the following syntax when naming the output reference:
-
The name must not contain 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, select one of the following return types:
-
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 output reference.
-
Map - returns the entire object for the next decision to use.
-
-
In the JavaScript tab, write the code for the decision template using Immediately Invoked Function Expression (IIFE). As you write your JavaScript, ensure that you consider the data limits in decisioning. To automatically format and indent the JavaScript code, click .
TipYou can create a form so your colleagues can further configure the decision without ever having to write, edit, or view code.
-
Click Save.
-
When you are ready to make the decision template available to the marketer, click the toggle switch to change the status to the Published state. The template then displays on the decision palette for the marketer to drag-and-drop onto the decision canvas.