IT CanvassTalk to an advisor
ServiceNow Examples · LessonBy , 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.
Set up your free instance →
Already working on ServiceNow and stuck on a live ticket?Get an expert ServiceNow developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support