How to get row count in fix script

Sivaprasath
Tera Contributor

Hi All,

In "certificate_cmdb_ci" table, I tried "group by" the record by serial number. There are 3 records with same serial number. when I used getRowCount, it gave me only one record.

find_real_file.png

var dup = new GlideAggregate('cmdb_ci_certificate');
dup.addEncodedQuery('u_sectigo_id!=NULL');
dup.addEncodedQuery('serial_number=123'); // this serial number is having 3 records
dup.groupBy('u_sectigo_id');
dup.query();
while(dup.next()) {
    var val = dup.getRowCount();
    gs.log(val) //returns only 1 value
}

Please assist me on the above doubt.

 

Thanks

Sivaprasath

1 REPLY 1

Community Alums
Not applicable

Dear Shiva ,

Please use below code to get rowcount .
If code working then please mark as helpful and correct 

var dup = new GlideAggregate('cmdb_ci_certificate');
dup.addEncodedQuery('u_sectigo_id!=NULL');
dup.addEncodedQuery('serial_number=123'); // this serial number is having 3 records
dup.groupBy('u_sectigo_id');
dup.query();

var count;
while(dup.next()) {
   count=dup.getRowCount();

}

  gs.info(count);