Is there any way to count the total number of records in a table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 01:22 PM
Is there any way to count the total number of records in a specific table? It doesn't have to have a certain field, I just want to count the total number of records.
I have already tried to use the following, but neither of them worked:
var count = new GlideAggregate('tableName');
count.addAggreate('COUNT');
count.query();
var records = 0;
if (count.next())
{
records = count.getAggregate('COUNT');
}
and also:
var grCount = new GlideRecord('tableName');
grCount.query();
var count = 0;
while (grCount.next())
{
count++;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 01:37 PM
Thank you for taking the time to reply! However, when I tried to use this I'm getting the same error as I did previously which says "GlideAggregate is not defined." (it says this in the console) Do you have an idea as to why it would say this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2017 01:44 PM
If you are writing this on a Client Script, you will have to use GlideAjax. Check the below link.
Re: How to use glideAggregate in client script
Please mark this response as correct or helpful if it assisted you with your question.