Your first user business rule script
A user business rule owns an event-driven script. The rule, not an API request, determines when it runs. Its subject is the entity that triggered the event.
- Create or edit a User Business Rule for the
Crm.Sales.SalesOrderLinesrepository. - Configure the rule's event, for example
COMMIT, and complete the other required rule settings. - Select
JavaScriptas the script language and enter this script text:
if (subject.Quantity != null && subject.Quantity.Value % 1 !== 0) {
Action.cancel("Enter a whole-number quantity.");
}
- Save and activate the rule, then try to save a line with a fractional quantity.
The script uses the triggering line directly; there is no managed-script args object or parameter schema. Action.cancel stops the operation with the given message. The configuration guide explains the rule fields, and business-rule examples show other event-driven patterns.