Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

PRINT INCIDENT CATEGORY HARDWARE & SOFTWARE WITH TOTAL COUNT IN GLIDERECORD

ARAVIND22
Tera Contributor

PLEASE HELP ME WITH THE BKOW SCRIPT TO GET THE TOTAL OF OF HARWARE AND SOFTWARE WITH LIST

 

var gr = new GlideRecord('incident');
gr.addQuery('category', 'software');

gr.addQuery('category', 'Hardware');
gr.query();
while(gr.next()){


OUTPUT NEEDED:

 

TOTAL NUMBER OF INCIDENT WITH HARDWARE CATEGORY IS  - 10

 

TOTAL NUMBER OF INCIDENT WITH SOFTWARE CATEGORY IS  - 12

 

Total number of incident is - 100

total number of incident with hardware and software is - 22

11 REPLIES 11

RaghavSh
Mega Patron

 

Refer : https://developer.servicenow.com/blog.do?p=/post/glideaggregate/  and use glide aggregate to achieve this kind of requirements.


Raghav
MVP 2023
LinkedIn

@RaghavSh  Bhai I want this in gliderecord without encoded query

You should use Glide Aggregate as it is more recommended and faster.

@ARAVIND22 addQuery and addEncodedQuery() fetches the same results, You can use any of them. 

Your question was just to print,  I thought its for learning purpose so I shared the link that would help you understand glideAggregate use cases.


Raghav
MVP 2023
LinkedIn