Create a decision template


How to create a decision template, which is a programmable decision that you configure and make available to other users on the decision palette.

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.

To create a decision template:

  1. In the navigation pane, click Library, Decision Templates. The Decision Templates screen displays.

  2. Click Create Template. The Title of template dialog box displays.

  3. 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.

  4. Click Create. The JavaScript template editor displays for you to customize using JavaScript.


    Sitecore 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.

  5. On the Settings tab, edit the name of the output reference 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.

  6. On the Settings tab, 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.

  7. In the JavaScript editor, 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.


    You can create a form so your colleagues can further configure the decision without ever having to write, edit, or view code.

  8. Click Save.

  9. When you are ready to make the decision template available to the marketer, change the status to Published.

    The template then displays on the decision palette for the marketer to drag-and-drop onto the decision canvas.