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.

How to Display info meaasge in List view

Madhan007
Tera Contributor

Hi all 
I have a Module that  displays the list of Group Records (sys_user_group) if the logged in User is a Manager or secondary manager of the group.
Now the ask is to display an info message if no records are displayed in the list view.
How can i do this?

Thanks in advance !

3 REPLIES 3

Amitoj Wadhera
Kilo Sage

Hi @Madhan007 ,

 

Create a query business rule:

if(current.getRowCount() === 0)
      gs.addInfoMessage('No records found.');

 

 

If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.

 

Thanks,

Amitoj Wadhera

Hi @Amitoj Wadhera , 
It showing the info message even when opened for a new Record

 

Amitoj Wadhera
Kilo Sage

Hi @Madhan007 ,

 

Please update your script to:

 

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

    var uri = gs.action.getGlideURI().toString();
    if (current.getRowCount() === 0 && uri.indexOf('list.do') > -1) {
        gs.addInfoMessage("Your message here");
    }

})(current, previous);

 

 

If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.

 

Thanks,

Amitoj Wadhera