Difference between script include and BR

jaiku
Giga Contributor

Difference between script include and BR

8 REPLIES 8

Karthik Reddy T
Kilo Sage

Hello Jai,



Script Include:


Create script includes to store JavaScript functions and classes for use by server scripts. Each script include defines either an object class or a function. Script includes run only when called by a server script.



https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/server_scripting/concept/c...



Script Includes - ServiceNow Wiki



Business rule:



A business rule is a server-side script that runs when a record is displayed, inserted, updated, deleted, or when a table is queried. A typical business rule might execute a script after a user updates an incident or escalates the priority of a change request.



Business Rules - ServiceNow Wiki



https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/script/business-rules/concept/c...


Karthik Reddy T.
ServiceNow Commnunity MVP -2018 class.

Script Includes exist primarily to re-use business logic code.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Rajesh Mushke
Mega Sage
Mega Sage

Hello Jai,



Script includes




Script includes are used to store JavaScript that runs on the server.


Create script includes to store JavaScript functions and classes for use by server scripts. Each script include defines either an object class or a function.


Consider using script includes instead of global business rules because script includes are only loaded on request.




Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

Shishir Srivast
Mega Sage

Business Rule is something you want to run when anything will happen before/after database update/insert for that record, definitely there are other options as well (like display and query business rule) etc.



Script Include is like re-usable function, in simple example if you want to calculate the date different of two date fields from incident form or change form then you can have 1 script include and can have a GlideAjax from client scripting to re-use them for both the places.