Creation of Major incident

Vikhyath
Tera Contributor

If there are 10 incidents raised for 1 Configuration item, It should automatically create a major incident.

1 ACCEPTED SOLUTION

Karan Chhabra6
Mega Sage
Mega Sage

Hi @Vikhyath,

 

I referred to the solution provided on this thread and I've modified the code to fit into your requirement.

https://www.servicenow.com/community/itsm-forum/to-create-a-major-incident/td-p/512373

 

Create a after insert/update business rule on the incident table and use this as the BR script:

var majInSys = "nothing";
var gaInc = new GlideAggregate('incident');
 gaInc.addActiveQuery();
 gaInc.addQuery('cmdb_ci', current.cmdb_ci);
 gaInc.addAggregate('COUNT');
 gaInc.orderByDesc('created');
 gaInc.query();
 
 if (gaInc.next()){
 
 var count = gaInc.getAggregate('COUNT');
 if (count == 10){
    var incGR = new GlideRecord("incident");
incGR.initialize();
incGR.major_incident_state = "Accepted";
incGR.short_description = "Major incident is created for 10 tickets with configuration item:" + current.cmdb_ci.getDisplayValue();
incGR.caller_id = ""; // you can use system admins sys_id here, store it in a system property
incGR.field = gaInc.field;    // map other fields

majInSys = incGR.insert();
 }
 }
 if (majInSys != "nothing"){
 var grIncU = new GlideRecord('incident');
 grIncU.addActiveQuery();
 grIncU.addQuery('cmdb_ci',current.cmdb_ci);
 grIncU.query();
 
 while (grIncU.next()){
 
 grIncU.parent = majInSys;
 grIncU.setWorkflow(false);
 grIncU.update();
 }
 }

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!

 

 

View solution in original post

4 REPLIES 4

AnubhavRitolia
Mega Sage
Mega Sage

@Vikhyath 

 

So you mean when there are 9 incidents for same CI, and as soon as 10th is added, new Major Incident should be created?

 

Also do you want to make it as parent of these 10?

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Yes, Exactly

Karan Chhabra6
Mega Sage
Mega Sage

Hi @Vikhyath,

 

I referred to the solution provided on this thread and I've modified the code to fit into your requirement.

https://www.servicenow.com/community/itsm-forum/to-create-a-major-incident/td-p/512373

 

Create a after insert/update business rule on the incident table and use this as the BR script:

var majInSys = "nothing";
var gaInc = new GlideAggregate('incident');
 gaInc.addActiveQuery();
 gaInc.addQuery('cmdb_ci', current.cmdb_ci);
 gaInc.addAggregate('COUNT');
 gaInc.orderByDesc('created');
 gaInc.query();
 
 if (gaInc.next()){
 
 var count = gaInc.getAggregate('COUNT');
 if (count == 10){
    var incGR = new GlideRecord("incident");
incGR.initialize();
incGR.major_incident_state = "Accepted";
incGR.short_description = "Major incident is created for 10 tickets with configuration item:" + current.cmdb_ci.getDisplayValue();
incGR.caller_id = ""; // you can use system admins sys_id here, store it in a system property
incGR.field = gaInc.field;    // map other fields

majInSys = incGR.insert();
 }
 }
 if (majInSys != "nothing"){
 var grIncU = new GlideRecord('incident');
 grIncU.addActiveQuery();
 grIncU.addQuery('cmdb_ci',current.cmdb_ci);
 grIncU.query();
 
 while (grIncU.next()){
 
 grIncU.parent = majInSys;
 grIncU.setWorkflow(false);
 grIncU.update();
 }
 }

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!

 

 

It's working Karan.

Thanks a lot for your help.