SUPPRESSING ONDISPLAY BUSINESS RULES IN POPUPS

Quite often we use onDisplay Business Rules to alert users from server side with some important information. This works pretty well but those info messages may be displayed multiple times.

The reason behind is that onDisplay Business Rules fire not only when you load a record form but also in popups when you just hover over (i) icon that is displayed to the left on every record in a list or on a reference field on the form. As a result the info messages that you add using gs.addInfoMessage() / gs.addErrorMessage() are saved in your session and displayed on the NEXT page which may lead to misunderstanding or duplicate info messages displayed on the form.

Let’s say we have a simple onDisplay business rule which purpose is to alert you when you land on the sys_user record with user_name = ‘admin’.Business Rule ServiceNow

It works pretty well on the form:

system Admin Form ServiceNow

However, if you, being in a list, hover over (i) icon near the record a couple of times and then navigate to a record or (which is even worse) hover over (i) icon in a populated reference field to display the details and then navigate to a new page (e.g. save incident where you hovered over Caller set to « System Administrator ») then the info messages will be displayed which proves that onDisplay Business Rule fires several times exactly when you just hovered over the record. No info messages immediately but on the next page. Argh what a pity!

screenshot3

System Administrator is Admin user

How to fix that:

Simply add a Condition to your onDisplay Business rule:

!RP.isPopup()

screenshot5

Now your onDisplay Business Rule will NOT run in popups.

 

This text was originally published on LinkedIn.

mm
Nikita is a certified ServiceNow Developer and Instructor and one of Fruition Partners (ex-Aspediens) Senior Consultants. He has a strong experience in architecture, programming and integration and worked on multiple large international deployments. If asked to sum up his job in a few words, Nikita will invariably smile and tell you "I deliver!"
Recent Posts

Leave a Comment

Start typing and press Enter to search