- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2022 11:45 PM
I have written below script to calculate the count of priority.I want to display the count of individiual priority.I am not able to display all three at once.
var gr = new GlideAggregate('incident');
var strQuery ='priority=1';
var strQuery1 ='priority=2';
var strQuery2 ='priority=3';
gr.addEncodedQuery(strQuery);
gr.addAggregate('COUNT');
gr.query();
gr.next();
var t1 = gr.getAggregate('COUNT');
gs.print(t1);
gr.addEncodedQuery(strQuery1);
gr.addAggregate('COUNT');
gr.query();
gr.next();
var t2 = gr.getAggregate('COUNT');
gs.print(t2);
gr.addEncodedQuery(strQuery2);
gr.addAggregate('COUNT');
gr.query();
gr.next();
var t3 = gr.getAggregate('COUNT');
gs.print(t3);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 12:00 AM
Hi Avinash ,
You can try the below script to print all at once .
var gr = new GlideAggregate('incident');
gr.addEncodedQuery('priorityIN1,2,3');
gr.addAggregate('COUNT', 'priority');
gr.query();
while (gr.next()) {
var incidentCount = gr.getAggregate('COUNT', 'priority');
var priority = gr.getValue('priority');
gs.info('Display the count {0} and priority{1} ', [incidentCount, priority]);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2022 11:52 PM
Hello @Avinash Dubey ,
You can follow below script and pass encoded queries
var agg = new GlideAggregate('incident');
agg.addAggregate('COUNT', 'priority');
agg.addEncodedQuery('priority=1');
agg.query();
while (agg.next())
{ //do things on the results
var incidentCount = agg.getAggregate('COUNT', 'priority');
gs.print('Display the count {0}', [incidentCount]);
}
MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 12:00 AM
Hi Avinash ,
You can try the below script to print all at once .
var gr = new GlideAggregate('incident');
gr.addEncodedQuery('priorityIN1,2,3');
gr.addAggregate('COUNT', 'priority');
gr.query();
while (gr.next()) {
var incidentCount = gr.getAggregate('COUNT', 'priority');
var priority = gr.getValue('priority');
gs.info('Display the count {0} and priority{1} ', [incidentCount, priority]);
}