Business rule : Display

ZebaT
Giga Contributor

I read community answer that Business rule: Display is used when say child incident task wants to get field value of parent table incident . Can someone give some other use case of this Display.

 

Thanks

7 ACCEPTED SOLUTIONS

GlideFather
Tera Patron

Hi @ZebaT,

 

display business rule is very powerful together with g_scratchpad.

 

When I used it the last time, it was when a requested item was loaded (= displayed), the BR checked where there is any pending approval for this particular RITM and if yes, it marked the scratchpad true, if no approval, scratchpad was false. And based on the scratchpad values a client script was hiding or keeping the Approval state field visible or not.

 

This use case was because most of the RITMs had an approval but a very few had no approval and the OOTB process showed field "Approval: Requested" and it was confusing for clients. Because there was no approval at all and thus it couldn't be Approved either... so we just hid the field described above :))))

_____
No AI was used in the writing of this post. Pure #GlideFather only

View solution in original post

Mohammed8
Giga Sage

Hi @ZebaT 

Your understanding is correct.

While working on the Work Order form, there was a requirement that if a Work Order is created from an Incident and if the Incident had High priority, the qualifier/initiator user should be aware of incident priority when the Work Order form opens. To achieve this, a Display Business Rule was used on the Work Order table to check the related Incident’s priority when form load. If the priority was High and an info message was displayed on the Work Order form using client script. Display business rule was chosen cause it does incident record server check.

 

Thanks and Regards,

Mohammed Zakir

View solution in original post

PrashantLearnIT
Tera Sage

Hi @ZebaT 

 

Display Business Rules (BRs) in platforms like ServiceNow are server-side scripts that execute before a form is presented to the user. Their primary purpose is to pass server-side data—such as field values or calculated results—to the client using the g_scratchpad object.

 

This allows client scripts to leverage that data for dynamic form behavior, including personalizing the form, showing or hiding fields, or setting default values, all without writing anything to the database.

 

Common use cases include auto-populating related task fields (for example, Assignment Group) when opening a new record from a parent record, displaying user-specific informational messages, and setting default values for fields that may not be directly present on the form.

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@ZebaT 

Consider an example:

-> when you open incident form there is a related list of incident task

-> now when you click New in Incident Task related list a new form of Incident Task is opened

-> Now if you want to grab some field value from INC which is parent of Incident Task you can use Display BR on incident_task

Example:

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

    // Add your code here
    gs.addInfoMessage("Parent INC description is" + current.parent.description);

})(current, previous);

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

ZebaT
Giga Contributor

Thanks for replies,

I read in community or chatgpt not sure, client + glideajax prefered if changes on form happens to pass value on fields from other record instead of display as display business rule only runs  on loads on form load right? Is my understanding/statement  correct?

Thanks

View solution in original post

sumityadav8
Tera Contributor

Hi @ZebaT 

A common requirement in ServiceNow is to check whether a record has attachments and then display that information to the user on the form. Since attachment checks (hasAttachments()) are only available server‑side, we use a Business Rule to evaluate this and pass the result to the client via g_scratchpad. The Client Script then consumes that value and shows it to the end user.

🖥️ Business Rule (Server‑side

(function executeRule(current, previous /*null when async*/) {
    if (current.hasAttachments()) {
        g_scratchpad.has = "Yes attachments are present";
    } else {
        g_scratchpad.has = "No attachments";
    }
})(current, previous);

      Runs on the record load,

Uses current.hasAttachments() to check if attachments exist & Stores the result in g_scratchpad.has.🌐 Client Script (Client‑side)Executes when the form loads,Reads the value from g_scratchpad.has&Displays a message to the user at the top of the form (or via alert).

 

function onLoad() {
    if (g_scratchpad.has) {
        g_form.addInfoMessage(g_scratchpad.has);
        // Alternative: alert(g_scratchpad.has);
    }
}

If My answer helped please mark it helpful & Accept as Solution

 

View solution in original post

@ZebaT 

Yes, Display Business Rules run only when the form loads and do not respond to field changes made on form. For scenarios where values need to be dynamically populated , a client script combined with GlideAjax is the preferred approach. This allows client-side events to trigger server-side logic and return data in real time

Here is link, you can check this too

https://www.servicenow.com/community/spm-forum/glide-ajax-or-display-br/m-p/1012617

 

Regards,

Mohammed Zakir

View solution in original post

7 REPLIES 7

GlideFather
Tera Patron

Hi @ZebaT,

 

display business rule is very powerful together with g_scratchpad.

 

When I used it the last time, it was when a requested item was loaded (= displayed), the BR checked where there is any pending approval for this particular RITM and if yes, it marked the scratchpad true, if no approval, scratchpad was false. And based on the scratchpad values a client script was hiding or keeping the Approval state field visible or not.

 

This use case was because most of the RITMs had an approval but a very few had no approval and the OOTB process showed field "Approval: Requested" and it was confusing for clients. Because there was no approval at all and thus it couldn't be Approved either... so we just hid the field described above :))))

_____
No AI was used in the writing of this post. Pure #GlideFather only

Mohammed8
Giga Sage

Hi @ZebaT 

Your understanding is correct.

While working on the Work Order form, there was a requirement that if a Work Order is created from an Incident and if the Incident had High priority, the qualifier/initiator user should be aware of incident priority when the Work Order form opens. To achieve this, a Display Business Rule was used on the Work Order table to check the related Incident’s priority when form load. If the priority was High and an info message was displayed on the Work Order form using client script. Display business rule was chosen cause it does incident record server check.

 

Thanks and Regards,

Mohammed Zakir

PrashantLearnIT
Tera Sage

Hi @ZebaT 

 

Display Business Rules (BRs) in platforms like ServiceNow are server-side scripts that execute before a form is presented to the user. Their primary purpose is to pass server-side data—such as field values or calculated results—to the client using the g_scratchpad object.

 

This allows client scripts to leverage that data for dynamic form behavior, including personalizing the form, showing or hiding fields, or setting default values, all without writing anything to the database.

 

Common use cases include auto-populating related task fields (for example, Assignment Group) when opening a new record from a parent record, displaying user-specific informational messages, and setting default values for fields that may not be directly present on the form.

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@ZebaT 

Consider an example:

-> when you open incident form there is a related list of incident task

-> now when you click New in Incident Task related list a new form of Incident Task is opened

-> Now if you want to grab some field value from INC which is parent of Incident Task you can use Display BR on incident_task

Example:

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

    // Add your code here
    gs.addInfoMessage("Parent INC description is" + current.parent.description);

})(current, previous);

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader