Search…
SDK and Frameworks
Import & Export Scripting Rules

How to import and export scripting rules?

File Structure

Imported & Exported files need to have some mandatory structural information:
  • name: name of the scripting rule
  • description: description of the scripting rule
  • type: type of the scripting rule
  • inputSchema: input schema of the scripting rule
  • outputSchema: output schema of the scripting rule
  • script: rules of the scripting rule
Type: there are two types:
  • "decision-table" - for decision tables
  • "complex-rule" - for scripting rules

Minimal File Structure Example:

1
{
2
"name": "",
3
"description": "",
4
"type": "",
5
"status": "",
6
"inputSchema": {
7
},
8
"outputSchema": {
9
},
10
"script": ""
11
}
Copied!

File Structure Example:

1
{
2
"name": "Multiply (Sample Script)",
3
"description": "Sample scripting rule",
4
"type": "complex-rule",
5
"status": "published",
6
"inputSchema": {
7
"value1": {},
8
"value2": {}
9
},
10
"outputSchema": {
11
"result": {}
12
},
13
"script": "/* \n 1. Input variables\n Input body is set in input variable \n*/\nlet a = input.value1;\nlet b = input.value2;\n\n/*\n 2. Define simple \"multiply\" function\n*/\nfunction multiply(a, b) {\n return a * b;\n}\n\n/*\n 3. Execute multiply function and store value result variable\n*/\nlet resultMultiply = multiply(a, b);\n\n/*\n 4. Set output model which is returned in REST API\n*/\noutput.result = resultMultiply;\n\n/*\n Optionally: It is possible print values to console\n*/\nconsole.log('Result multiply:', resultMultiply);\n\n/*\n 5. Return output \n*/\nreturn output;"
14
}
Copied!