Regarding priority in incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 09:26 PM
I want to calculate the count of all the p1,p2 and p3 incidents in last 3 months. please provide script for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 09:40 PM
Hi @SNOW24 ,
Please try this code for getting the required row count.
var grc = new GlideRecord('incident');
grc.addEncodedQuery('active=true^priorityIN1,2,3^sys_created_onONLast 3 months@javascript:gs.beginningOfLast3Months()@javascript:gs.endOfLast3Months()');
grc.query();
if(grc.next())
{
gs.addInfoMessage(grc.getRowCount());
}
If it is helpful please mark it correct.
Thanks and Regards,
Allu Gopal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 10:03 PM
Hi @SNOW24 ,
Please use the below code -
var count = 0;
var inc = new GlideAggregate('incident');
inc.addEncodedQuery('priority=1^ORpriority=2^ORpriority=3^sys_created_onONLast 3 months@javascript:gs.beginningOfLast3Months()@javascript:gs.endOfLast3Months()');
inc.addAggregate('COUNT');
inc.query();
if(inc.next()){
count = inc.getAggregate('COUNT');
}
gs.info(count);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 10:18 PM
Here is a simpler version of the encodedQuery
inc.addEncodedQuery('active=true^priority=1^ORpriority=2^ORpriority=3^sys_created_on>javascript:gs.beginningOfLast3Months()');
hope this helps
--
Bala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 11:01 PM
Hi @SNOW24 ,
Why do you want to create a script for what there can be done through the report designer?
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/