May 28, 2023

Display Business Rules in ServiceNow

 There are four types of Business Rules in ServiceNow

  1. Before business rules
  2. After business rules
  3. Display business rules
  4. Async business rules

In ServiceNow, Display Business Rules are a type of business rule that allows you to control the visibility and behavior of form elements (fields, sections, related lists, etc.) on a form in the user interface.

Display Business Rules run when a user requests a record/load a form, data has been retrieved from the database, and before the form is presented back to the user.

Display Business Rules use g_scratchpad object to store server-side script results and send them to the client-side. Display Business Rules execute their logic when a form loads and a record is loaded from the database. They must complete execution before control of the form is given to a user.

Client-Scripts only have access to fields and field values for fields on the form and not all of the fields from the database. Use the g_scratchpad object to pass data to the client-side without modifying the form. The g_scratchpad object has no default properties.

How to use Display Business Rules:

  • Create a display business rule as per your requirement (conditions).
  • Use g_scratchpad object to store data from server-side and send to the client-side.
  • Use g_scratchpad object properties to manipulate/process form-level data.
// From client script 
if(g_scratchpad.someName == "someValue") { 
  //do something special 
}


0 comments: