For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create Simple Scripting Rule

This tutorial will walk you through the creation of a simple Scripting Rule.

How to create a simple decision table

Let's advance one step at a time.

1. Create a new Scripting Rule

To display the rules creation list, click the + Create button on the search bar. Select your rule and you will be prompted to provide a name. For this example, select a name for your rule as you wish and press "Confirm". The new rule will be created and its design interface will be displayed. We will continue in the Rule Setting menu.

2. Make basic settings

Rule Settings will be in a left-hand side menu, or you can access them by Rule Model at the top bar. Let's do some settings. Since we do not want this decision table to be available yet, we will change its status to Pending. To do this, switch on the current status Published to Pending.

To apply these changes, we have to click the Save button at the top of the page, right corner.

3. Create an Input and Output model

We will now create an input and output model, which we will then use to set conditions and results. We create this model with a JSON editor.

After creating an input or output model, we must always confirm the changes with the Save button.

Input model

First, we delete all created objects. Then we will add our specified requirements (value1, value2) as empty objects. Let's start with the input model. First, you can switch from "Designer" to "Model" at the centre of the top bar. Change from Simple Editor to JSON Editor at the toggle next to the "Rule Settings" button. Delete all default objects. Then add your specified requirements, e.g. value1, value2, as empty objects.

Because our model is simple, these objects do not contain any others. For more complex models, more information is here.

Input model Example:

Output model

We set the output model similarly, where we set it as root result (empty object).

Output model Example:

4. Creating rules

Now let's move on to code editor by clicking on Scripting Rule Designer it in the upper center and create individual rules.

For simplicity, we will remove the code from the code editor to create a new rule.

When to code editor is empty, we can start to create our own rule in JavaScript. It is straightforward, and you need to write your code which can look like below.

console.log() is forbidden due to performance, but you can use log() instead.

Always save your script using Save (bottom of the page) or CTRL/CMD + S

5. Test created scripting rule

Now we can test our rule. Before testing the rule, we must change the status of the rule to "Published".

If we want to test a rule, we can click on the Test Bench button. An input and output window will show up at the bottom of the page. Press the Run icon at the center of the window.

The result will be displayed in the Output window (the right one).

The debug mode can be turned on by clicking on Debug off . In scripting rules, it will enable to write log() in the console.

Request body example:

Response body example:

More information about Test Bench is here.

Last updated