ServiceNow Examples · LessonBy Neelima, ServiceNow Architect · Published · current release · reference
Business rule examples
Before, after and async business rule patterns.
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.Try it YourselfJavaScript
▸ Press Run to execute.
Runs in a sandbox in your browser. Mock gs and GlideRecord and sample data are provided.
Quick check
+0 XPStreak ×0
Question 1 of 2
Which business rule type can abort a save?
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.
Practise this on your own free instance.