What is the difference between a business rule and script include?

vsashwin364
Kilo Contributor

Hi I am a newcommer to ServiceNow - exploring the platform. I know both are server-side script, but what makes them different.

 

7 REPLIES 7

Lakshmi888888
Kilo Guru

Hi  @vsashwin364 ,

 

On a high level,

 

A Business Rule is a trigger-based server-side script that runs automatically during database operations, whereas a Script Include is a reusable library of code that only runs when explicitly called. Both operate on the server side, but they serve different purposes in ServiceNow.
 
Execution and Trigger

 

  • Business Rule:
    • Runs automatically.
    • Triggers during database CRUD actions (Insert, Update, Delete, Query, or Display) on a specific table.
    • Configured using form settings (Before, After, Async, Display) and conditional filters.
  • Script Include:
    • Runs only on demand.
    • Executes when called by other server-side scripts (like Business Rules or Workflow scripts) or via client-callable GlideAjax.
    • Does not watch tables or trigger automatically. 
Purpose and Reusability

 

  • Business Rule:
    • Handles record-specific database logic.
    • Enforces data integrity, auto-assigns values, or initiates background actions for a specific record lifecycle. 
  • Script Include:
    • Promotes code reuse and modularity.
    • Stores centralized functions or classes so you do not repeat the same block of code across multiple rules or applications

Please mark this response as Helpful or Correct if it helped.

Vinayak2443
Tera Contributor

Hi @vsashwin364 

Business Rule

A Business Rule is a server-side script that runs automatically when a record is inserted, updated, deleted, or displayed. You use it to automate actions based on these record events. It is triggered by the database operation—you don't call it yourself. You simply define when it should run (like Before, After, Async, or Display) and ServiceNow executes it automatically.

When to run:

Before – Runs before the record is saved to the database. We can use it to validate or modify data before it is stored.
After – Runs after the record has been saved to the database. We use it when we need to perform actions that depend on the record already existing in the database, such as updating related records or sending notifications.
Display – Runs before the form is displayed to the user. We use it to prepare data (using g_scratchpad) that a Client Script needs when the form loads.
Async (Asynchronous) – Runs after the record is saved, but in the background. We use it for tasks that don't need to happen immediately, such as sending emails, calling external systems, or for long-running processing, so the user doesn't have to wait for them to finish.

Script Include

A Script Include is a server-side script that contains reusable functions or classes. Unlike a Business Rule, it does not run automatically. It is triggered only when another script calls it, such as a Business Rule, UI Action, Scripted REST API, another Script Include or via a Client Script(using GlideAjax). You use it to write code once and reuse it in multiple times.

There are three types of Script Includes:

Classless – Standalone functions (less commonly used).
Class-based – Reusable methods inside a class (most commonly used).
Client Callable – Called from a Client Script using GlideAjax.

Hope you find it helpful.

yashkamde
Giga Sage

Hello @vsashwin364 ,

 

Business RuleScript Include
Executes automatically based on database operations (Insert, Update, Delete, Query, Display).Executes only when called from another script (Business Rule, Scripted REST API, Flow Action, UI Action, etc.).
Event-driven.Function/Class-based and reusable.
Mainly used to enforce business logic, validate data, or automate actions on records.Mainly used to write reusable logic that can be shared across multiple scripts.
Tied to a specific table.Not tied to any table (unless designed that way).
Runs Before, After, Async, or Display.No execution timing—it runs whenever another script invokes it.
Reduces manual intervention by triggering automatically.Reduces code duplication by centralizing common logic.
Cannot be directly called from another script like a function.Can be called from server-side scripts and, if Client Callable, from client scripts via GlideAjax.

 

Example :
Business Rule :

 

// Suppose whenever an Incident is created with Priority = 1, you want to automatically assign it to the Major Incident team.
// Before Insert Business Rule

if (current.priority == 1) {
    current.assignment_group = 'Major Incident Team Sys ID';
}

 

Script Include :

 

// Now if the same logic is required in multiple places (Business Rule, Scripted REST API, Flow Designer Action, etc.)

var IncidentUtils = Class.create();
IncidentUtils.prototype = {
    initialize: function() {},

    assignMajorIncident: function(current) {
        if (current.priority == 1) {
            current.assignment_group = 'Major Incident Team Sys ID';
        }
    },

    type: 'IncidentUtils'
};

 

call this in BR any anywhere server side for reusability :

var utils = new IncidentUtils();
utils.assignMajorIncident(current);

 

If my response helped mark as helpful and accept the solution.

Ankur Bawiskar
Tera Patron

@vsashwin364 

answer to this question can be easily found on any AI tool or Google or ServiceNow Docs

what did you find and what are your doubts?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader