Scripting Rules

Introduction

Scripting Rule is another type of rule that you can use in DecisionRules to create your rules and conditions. However, it differs fundamentally from the others in that it does not have a graphical editor, it uses the Monaco code editor instead.

Just like the other rules, it has a unified Rule Settings form that is the same across all rule types.

Next, you move to the Scripting Rule Designer and create the rule and all the logic using JavaScript.

The Scripting Rule Designer uses the standard and well-known Monaco editor from VS Code to help the user with code creation and editing. Of course, it also includes all the Functions and Operators that are available in Decision Table or Decision Tree.

Below you can find example file with Scripting Rule. This rule contains a function that return random number from given range.

What is important to note is that you should always have β€œreturn output;” in the last line of your Scripting rule.

Intended Users and Use of the Scripting Rule

Although DecisionRules is a No-code & Low-code solution, in some cases it is useful to take advantage of the flexibility that using the code offers. In particular the ability to create your own function or copy it from already created code. Using Scripting Rule is mainly meant for Developers, Analysts or anyone who is capable and willing to use JavaScript.

One of the most popular use cases is when a developer creates a generic script that processes data. This script then changes very little, because all the parameterization of that script happens in the Decision Table or Decision Tree, where it is already being modified by people from the business or product teams.

Rule Orchestration

GitHub

Whenever you make a change to a rule, save it with the Save button.

Summary

Thanks to Scripting Rules, DecisionRules can have the Best of Both Worlds.

Scripting Rule allows you to create custom functions, make advanced data manipulation, aggregations, iterations. You can also very easily copy functions and code that you have already created in JavaScript.

Last updated