- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 09:48 PM
Hello All,
I do not understand what the difference is between getRowCount and getAggregateCount. can anyone please guide me on this?
Thank You.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 10:36 PM
Hi @Sagar_pawar ,
getRowCount - Used to get the Row count but it is not recommanded for any aggregate operation use GlideAggregate.
GlideAggregate
GlideAggregate used to do database aggregation operations(Count, Min, max, sum, AVG, etc..)
Refer below link for GlideAggregate methods with examples.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 09:54 PM - edited ‎12-22-2022 09:56 PM
Glide Aggregate is a service-now class for mathematical functions like sum, count min , max etc. getAggregateCount is the recommended function.
getRowCount() is used with glideRecord class but that is not recommended by servicenow. for any mathematical operations glideAggregate is the recommended way, even if they return same results.
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 10:10 PM
Hi @Sagar_pawar
You can either use the getRowCount() method from GlideRecord, or just use GlideAggregate.
Using GlideRecord to count rows of records will cause scalability issues as tables can grow over time. This method retrieves every record and counts them. GlideAggregate retrieves the data from the actual MySQL database that's built in to ServiceNow, which is much faster when it comes to performance.
The GlideAggregate class is an extension of GlideRecord and allows database aggregation (COUNT, SUM, MIN, MAX, AVG) queries to be done. This can be helpful in creating customized reports or in calculations for calculated fields
If you find this answer helpful, please mark it as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 10:12 PM - edited ‎12-22-2022 10:14 PM
Hi Abhi ,
getRowCount is used in GlideRecord while getAggregateCount is use in GlideAggregate .
Servicenow promotes using GlideAggregate as it is much faster then using GlideRecord then getRowCount.
Also if you used getRowCount it might affect the upgrade score in your instance as this will be pointed out when you perform instance scanning .
Hope this helps you.
Regards,
Edgar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2022 10:19 PM
Blue background in the screenshot is the Object used.
Yellow background is the data available in the objects (gr for GlideRecord & ag for GlideAggregate)
Thanks & Regards,
Vasanth