Business - When: Display
- Execute after the data is read from the database and before the form is presented to the user
- Primary purpose if to populate g_scratchpad global object
- Example: Provide Client Scripts with access to data from other records
Display Business Rule execute when a user requests a record form. Data is read from the database, the Display rules are executed, and the form is presented to the user.
The g_scratchpad global object has no property/value pairs unless populated by a Display Business Rule. For example, the sys_created_by and sys_created_on fields are not part of the Incident form. To access their values from a Client Script would require a call to the server. Server calls are expensive from a processing time perspective and should be avoided. Instead, the Display Business Rule populates g_scratchpad object when form loads and the Client Script reads the values from g_scratchpad object.
Display Business Rule
g_scratchpad.createdBy = current.sys_created_by;
g_scratchpad.caller = current.caller_id;
g_scratchpad.callerDV = current.caller_id.getDisplayValue();
Client Script
if(g_scratchpad.createdBy == "admin"){
g_form.setValue("opened_by", g_scratchpad.caller, g_scratchpad.callerDV);
}