- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 01:47 AM
Hi,
I want to display a message if the list view is blank for a table, but my message shows even if the table is not blank because getRowCount is giving the wrong result.
For this I have written a before-query BR:-
(function executeRule(current, previous /*null when async*/) {
var index = gs.action.getGlideURI().toString().indexOf('kb_knowledge_list'); //It checks for list view, i.e. "_list" is there in UR L if the List view appears
var count = current.getRowCount();
gs.addInfoMessage(count);
if(index != -1 && count == 0)
{
var c='No matches found for the search item';
gs.addInfoMessage(c);
}
else
{}
})(current, previous);
When the table is not blank, the value of "count" is still 0, and if the table is blank, the count is still 0.
Please help.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 02:01 AM
This function doesn't work with current, so simply define a GlideRecord to kb_knowledge table adding the query as per your need:
var gr = new GlideRecord('kb_knowledge');
gr.addQuery(<add your condition>);
gr.query();
var count = gr.getRowCount());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 01:54 AM
Hi,
you have to call the function getRowCount() defining a GlideRecord in your Business Rule script, below an example:
var gr = new GlideRecord('incident');
gr.query();
var count = gr.getRowCount());
Hope this can help you!
If I have answered your question, please mark my response as correct and/or helpful so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thank you
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 01:58 AM
Hi,
But i have created this BR on the kb_knowledge table. So why does "current" not work with getRowCount as the "current" refers to the table on which the BR is based?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 02:01 AM
This function doesn't work with current, so simply define a GlideRecord to kb_knowledge table adding the query as per your need:
var gr = new GlideRecord('kb_knowledge');
gr.addQuery(<add your condition>);
gr.query();
var count = gr.getRowCount());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 02:51 AM
Can you help me with the query pls?
I have written new question here for it... Thanq.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2019 02:48 AM
why are you changing the correct answer again and again ?