Getting started with business-rule scripts
The scripting feature in ERP.net is accessible from specific modules and workflows, such as user-defined business rules within your instance.
It allows you to embed custom logic directly where business decisions or specific custom processes are required.
How to create a script
Note
The examples below are tailored for scripting within User Business Rules.
Navigate to a module where scripting is supported (e.g., User Business Rules).
Create a new rule or edit an existing one.
In the Script Language attribute, select the desired scripting language/platform, and enter your script in the Script Text field.
Note
JavaScript is the recommended and officially supported scripting language.
Complete the remaining required fields for the user business rule- such as when it should be triggered, the context repository, etc.
Save.
Done.
The script runs when the configured rule event occurs while the rule is active.
Your first script
A classic way to get started with scripting is to log a simple message. The following example demonstrates how to write "hello world" to the system log whenever the rule is triggered:
Action.log("hello world");
Once the rule containing this script is activated, you'll see "hello world" appear as a new information message.
This serves as a simple test to confirm that your scripting environment is working correctly.
Note
The Action variable is the global action object. Its methods and context requirements are documented in the Developer Documentation.