Row count

sasi
Tera Contributor

Hi,

i want Row count by using glide object. please explain me with the script.

 

Thanks.

1 ACCEPTED SOLUTION

Ritanjali Pati
Mega Expert

Hi Sasi,

To test your code go to navigator-->Background script and run the following script: 

var gr=new GlideRecord("incident"); //glide the table you want to count rows


gr.addQuery('active', true); //shows all active records
gr.query(); // query the condition

 gs.print(gr.getRowCount()); // counts all the active incidents and prints the number


while(gr.next())
{
gs.print(gr.number);
}

 

If you got the satisfied answer please mark my answer as correct and helpful.

 

Thanks,

Ritanjali, www.dxsherpa.com

View solution in original post

6 REPLIES 6

Omkar Mone
Mega Sage

Hi 

var gr = new GlideRecord('sys_user');
gr.addQuery('active',true);
gr.query();


gs.print(gr.getRowCount());

 

This will get you the count of alll active users in your servicenow instance.

 

Mark correct if it helps.

 

Regards,

Omkar Mone.

www.dxsherpa.com

Hi 

Please mark correct answer if it helped you to close the thread. 

 

Thanks.

SaiRaviKiran Ak
Giga Guru

You can use gr.getRowCount(); to get the row count

Chalan B L
Giga Guru

Hello Sasi,

Left Nav --> Background scripts

Run the below code

------------------------------------------

var gr = new GlideRecord('incident'); //Gliding the incident table

gr.addEncodedQuery('active=true'); //Filtering the table by having a filter where it returns only active true records

gr.query();

gs.print('<Row Count >'+gr.getRowCount()); //Prints the active true records count

--------------------------------------------

Example:

find_real_file.png

After Executing the Script

find_real_file.png

 

 

Mark the answer as correct and helpful, if it helped you..!!!

 

Regards,

Chalan