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’.
It works pretty well on the form:
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!
How to fix that:
Simply add a Condition to your onDisplay Business rule:
!RP.isPopup()
Now your onDisplay Business Rule will NOT run in popups.
This text was originally published on LinkedIn.
The post SUPPRESSING ONDISPLAY BUSINESS RULES IN POPUPS appeared first on Fruition Partners - ServiceNow Gold Partner.