- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:09 PM
Hi,
i want Row count by using glide object. please explain me with the script.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:50 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:11 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:35 PM
Hi
Please mark correct answer if it helped you to close the thread.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:14 PM
You can use gr.getRowCount(); to get the row count

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:17 PM
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:
After Executing the Script
Mark the answer as correct and helpful, if it helped you..!!!
Regards,
Chalan