How to count the number of records in a table?

kishorchika
Tera Contributor
 
4 REPLIES 4

pranita-24
Tera Guru

Hi 
You can try this
var gr = new GlideRecord('incident');
gr.query();
gs.info(gr.getRowCount());

Ankur Bawiskar
Tera Patron
Tera Patron

@kishorchika 

You can easily get answer to your question by doing a google search.

It will save a lot of time and effort.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Bhuvan
Mega Patron

@kishorchika 

 

There are many options to get the number of records in a table. You can use Glide Record with getRowCount() or use Glide Query with count(). You can also use addQuery or addEncodedQuery or where conditions to filter the data and get the count details.

 

https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/...

 

https://www.servicenow.com/docs/bundle/zurich-it-business-management/page/product/project-workspace/...

 

As per community guidelines, you can accept more than one answer as accepted solution. If my response helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

aneta_koleva
Tera Expert

hi Kishorchika. Easiest way is to add an Aggregation Query data resource: 

aneta_koleva_0-1759231408300.png

You can specify the table you are interested in: 

aneta_koleva_1-1759231457332.png

and in the Output you will get the count 

aneta_koleva_2-1759231495959.png

 

 

Mark my answer Helpful in case you find it as such.