- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 03:59 AM
If there are 10 incidents raised for 1 Configuration item, It should automatically create a major incident.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 05:13 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 04:44 AM
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?
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 04:47 AM
Yes, Exactly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 05:13 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 01:46 AM
It's working Karan.
Thanks a lot for your help.