Business rules
Run server-side logic when records are saved or read.
Business rules are server-side scripts that run when records are queried, inserted, updated or deleted. Because they act at the database layer, they enforce logic no matter how the record changed, form, import or API, which makes them the workhorse of server automation. The skill is choosing the right when and current/previous semantics.
- When they run
- current, previous, and change detection
- Keep logic reusable
- Business rule vs data policy vs flow
- Common mistakes
Business rules are server-side scripts that run when records are queried, inserted, updated or deleted. Because they act at the database layer, they enforce logic no matter how the record changed, form, import or API, which makes them the workhorse of server automation. The skill is choosing the right when and current/previous semantics.
When they run
current, previous, and change detection
Inside a rule, current is the record now and previous is its pre-change state. Detect transitions precisely:
current and the platform saves them, never call current.update(), which causes recursion. In an after rule you touch other records with a fresh GlideRecord.Keep logic reusable
A business rule should orchestrate, not hold hundreds of lines. Put shared functions in a Script Include and call it from the rule, so the same logic serves multiple rules, flows and APIs.
Business rule vs data policy vs flow
current.setAbortAction(true)).Common mistakes
- Calling
current.update()inside a before rule, recursion; just set the field. - Heavy queries in a synchronous rule, slowing every save, move to async.
- Duplicating logic across rules instead of a shared Script Include.
- Using a business rule where a data policy or flow was the right tool.
▸ Press Run to execute.
Runs in a sandbox in your browser. Mock gs and GlideRecord and sample data are provided.