Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Add info message to top of list view using Before Query Business Rule

ChadLee4
Tera Contributor

I have a Before Query business rule that adds an info message to a list view.

 

I am running into an issue when the list view query uses "GROUPBY", the query seems to run twice and display the message twice.

 

Is there a workaround to this? Or a different way to add an info message to the top of a list view?

 

Code:

    var _strCurrentURL = (gs.action.getGlideURI() || "").toString();
    if (_strCurrentURL.contains("_list.do")) {
        gs.addInfoMessage("Info Message");
        }
    }
7 REPLIES 7

This makes the query run twice. Unless I am inserting the line of code in the wrong place.

sunil maddheshi
Tera Guru

@ChadLee4 

Can you try with below code :

if (!gs.getSession().getProperty('info_message_shown')) {
    var _strCurrentURL = (gs.action.getGlideURI() || "").toString();
    if (_strCurrentURL.contains("_list.do")) {
        gs.addInfoMessage("Info Message");
        gs.getSession().setProperty('info_message_shown', 'true');
    }
}

Please mark correct/helpful if this helps you!

I tried this and it does not display any info messages