- 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: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 11:15 PM
Use GlideAggregate for Simple Record Counting
If you need to count rows, you have two options: the getRowCount() method from GlideRecord, or GlideAggregate. Using GlideRecord to count rows can cause scalability issues as tables grow over time, because it retrieves every record with the query and then counts them. GlideAggregate gets its result from built-in database functionality, which is much quicker and doesn’t suffer from the scalability issues that GlideRecord does.
For more details refer this,
Read this for GlideAggregate concept
https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=c_GlideAggregateAPI