ServiceNow Business Rule


A business rule is a server-side script that runs when a record is displayed, inserted, updated, or deleted, or when a table is queried.

Use business rules to accomplish tasks like automatically changing values in form fields when certain conditions are met, or to create events for email notifications and script actions.

How Business Rules Work?

To configure business rules, you first need to determine when the business rule should run and what action it should take.

When Business Rules Run:

Business rules run based on two sets of criteria:

  • The time that the business rule is configured to run relative to a record being modified or accessed.
  • The database operation that the system takes on the record.

1. Before:
After the user submits the form but before any action is taken on the record in the database.

2. After:
After the user submits the form and after any action is taken on the record in the database.

3. Async:
When the scheduler runs the scheduled job created from the business rule. The system creates a scheduled job from the business rule after the user submits the form and after any action is taken on the record in the database.

4. Display:
Before the form is presented to the user, just after the data is read from the database.

Note: Asynchronous business rules do not have access to the previous version of a record. Therefore, the changes(), changesTo(), and changesFrom()GlideElement methods do not work with async rule script. However, the condition builder and condition field (advanced view) both support the changes(), changesTo(), and changesFrom() methods.

The following options are provided to determine the database operation that the system takes on the record

1. Insert:
When the user creates a new record and the system inserts it into the database.
2. Update:
When the user modifies an existing record.
3. Query:
Before a query for a record or list of records is sent to the database. Typically you should use query for before business rules.
4. Delete:
When the user deletes a record.

Business Rule Actions:

  • Changing field values on a form that the user is updating. Field values can be set to specific values available for that field, values copied from other fields, and relative values determined by the user’s role.
  • Displaying information messages to the user.
  • Changing values of child tasks based on changes to parent tasks.
  • Preventing users from accessing or modifying certain fields on a form.
  • Aborting the current database transaction. For example, if certain conditions are met, prevent the user from saving the record in the database.

Creating a Business Rule:

⦁ Navigate to System Definition > Business Rules.
⦁ Click New.
⦁ Fill in the fields, as appropriate.

⦁ Click Submit.

Note: Some fields are only visible when the advanced check box is selected.

Sample Business Rule Script

Example: Prevent closure of problem if problem task is not closed

When: before
Insert: false
Update: true
Delete: false
Query: false

Table: problem

Filter Conditions: State–> Changes to –> Closed/resolved


(function executeRule(current, previous /*null when async*/) {

var gr = new GlideRecord(‘problem_task’);
gr.addQuery(‘problem’,current.sys_id); //table name here
if ( {
gs.addInfoMessage((‘Please Close all the problem Tasks’)); //info message here
current.state = previous.state;

0 0 vote
Article Rating
Inline Feedbacks
View all comments