Get number of records returned in GlideRecords

Eli Guttman
Tera Guru

Hi,

Is there a way to check the number of returned records using GlideRecord and not GlideAggregate?

I need to query a record, but if the query return more than one result, i need do something else.

I know that i can do GlideAggregate with COUNT, and then do another GlideRecord, but i was wondering if i can do it in one Glide call.

 

Thank you!

1 ACCEPTED SOLUTION

Rajesh Annepak1
Kilo Guru

Hi 

 

Please check using GlideRecord --> GetROWCOUNT Method 

 

var gr = new GlideRecord('incident')
gr.query();
gs.info("Records in incident table: " + gr.getRowCount());


Please mark helpful / Correct , If your query is resolved

Rajesh Kumar Annepaka

View solution in original post

2 REPLIES 2

yash755
Tera Contributor

Hey, 

This is also a way to count.

 

var count = 0;

 

  var gr = new GlideRecord('change_request'); // write your table name

 

  gr.addQuery('active',true); // write appropriate query

 

  gr.query();

 

  while(gr.next()){

 

  count = count+1;

 

  }

 

  alert("Count is : " +count);

Rajesh Annepak1
Kilo Guru

Hi 

 

Please check using GlideRecord --> GetROWCOUNT Method 

 

var gr = new GlideRecord('incident')
gr.query();
gs.info("Records in incident table: " + gr.getRowCount());


Please mark helpful / Correct , If your query is resolved

Rajesh Kumar Annepaka