Discrepancy Between GlideRecord.getRowCount() and Actual Table Count in cmdb_sam_sw_install

jeevanjadhav
Giga Contributor

Hi Everyone,

I'm encountering a discrepancy between the number of records retrieved using a background script and the actual count shown in the cmdb_sam_sw_install table UI.

Here’s the script I’m running:

var installGR = new GlideRecord('cmdb_sam_sw_install');

installGR.query();

gs.info('Matching Software Installs Count: ' + installGR.getRowCount());

This script outputs:

Script: Matching Software Installs Count: - 427991

However, when I check the same table in the UI (with all filters cleared), the total number of records displayed is 410,910.

I’d like to understand:

  • Why is getRowCount() returning more records than what I see in the table UI?
  • Could this be due to ACLs, replication lag, or some other issue?
  • What’s the best way to ensure the script returns a count that matches what users see in the UI?
4 REPLIES 4

Di Zhang
Tera Guru

It was effected by ACL.  if you need to get results same as UI, you should use GildeQuery

di_zhang3_0-1752649803962.png

 

Ankur Bawiskar
Tera Patron
Tera Patron

@jeevanjadhav 

GlideRecord won't consider ACL.

Check any Table level READ ACL or Query business rule is restricting records.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@jeevanjadhav 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Pranesh072
Mega Sage
Mega Sage

You can use GlideRecordSecure which enforce ACLs. Most probably there can be query BR which is restricting the records.