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  

Regarding priority in incident form

SNOW24
Tera Contributor

I want to calculate the count of all the p1,p2 and p3  incidents in last 3 months. please provide script for this.

7 REPLIES 7

Gopal Allu
Tera Expert

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.

Anirudh Pathak
Mega Sage

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);

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

AndersBGS
Tera Patron
Tera Patron

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/