how to group incidents

M Lohith Datta
Tera Contributor

Hi,

My doubt is that once we receive a flood(>100) of incidents in 5 min time then from those incidents can we separate or group incidents based on CI ? and once we sort or group them by CI if there are more than 10 incidents in any groups then for that group can we create a major incident and attach the remaining incidents to the major incident? is there any way in scripting to achieve this? if so please help 

Thanks

Datta

 

@Ankur Bawiskar Kindly help me with above doubt

 

1 ACCEPTED SOLUTION

Hi,

try this

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var agg = new GlideAggregate('incident');
	agg.addAggregate('COUNT', 'cmdb_ci');
	agg.addEncodedQuery('sys_created_onRELATIVEGT@minute@ago@60');
	agg.addQuery('cmdb_ci', current.cmdb_ci);
	agg.query();
	while (agg.next()) {
		//do things on the results
		var incidentCount = agg.getAggregate('COUNT', 'cmdb_ci');
		gs.addInfoMessage('Total incidents for this CI ' + incidentCount);
		
		if(incidentCount > 20){
			// your logic
		}
	}

})(current, previous);

Regards
Ankur

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

View solution in original post

7 REPLIES 7

Jaspal Singh
Mega Patron
Mega Patron

Did you try Group By functionality?

Right click the column header & then group it

find_real_file.png

Hi Jaspal, 

Thanks for the reply, But I am looking for a script to do it 

And I am looking to automate the whole process mentioned above

Thanks

Datta

You need to use GlideAggregate. Look for link

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Use GlideAggregate and get the count

Link already shared by Jaspal

You can start from your side and it would be learning for you as well.

Regards
Ankur

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