Business rule examples
Quick answer
Business rules run on the server around database operations. These patterns cover the everyday cases.
Key takeaways
- Set a field before insert
- Abort a save with a message
- Trigger side effects after insert
Business rules run on the server around database operations. These patterns cover the everyday cases.
Set a field before insert
// When: before, insert
current.setValue('u_source', 'portal');Abort a save with a message
// When: before, update
if (current.priority == 1 && !current.assignment_group) {
gs.addErrorMessage('P1 needs an assignment group');
current.setAbortAction(true);
}Trigger side effects after insert
// When: after, insert
var t = new GlideRecord('task_sla');
// ...create related records, notifications, etc.Want to learn this properly?
Our live, instructor-led ServiceNow Training covers this hands-on, with real projects and a certification path.
Check your understanding
Which business rule type can abort a save?
- A. before
- B. after
- C. async
Show answer
A. before
Before rules run prior to the write and can setAbortAction(true).
Where should you create related records after save?
- A. after rule
- B. before rule
- C. client script
Show answer
A. after rule
After rules run once the record is committed.
Frequently asked questions
What does the term Business rule examples refer to in ServiceNow?
Business rules run on the server around database operations. These patterns cover the everyday cases.