- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2019 05:37 AM
Hi All,
I would like to auto resolve all the related incidents when a Change is moved to closed state.
Is it possible ? can anyone share some ideas.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2019 05:56 AM
This is a variation on a business rule I had used for Problem to resolve related incidents, it should do the trick for you; or at least point you in the direction.
if (current.state.changesTo(3)) {
notifyRelatedIncidents(current);
}
//
// Notify any incidents that are related to the current change
//
function notifyRelatedIncidents(me) {
var incident = new GlideRecord("incident");
incident.addQuery("rfc", "=", me.sys_id);
incident.query();
while (incident.next()) {
if (incident.active == true){
var msg = "Associated change request " + me.number + ' closed with the following close notes.\n' + 'Close Notes:\n' + me.close_notes;
if(incident.state != 6,7){
incident.state.setValue(6);
}
incident.work_notes = msg;
incident.update();
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2019 05:44 AM
Greetings Tamil,
You can use a flow, a workflow, or a business rule to handle this. You will need to query for the related incidents and close them. If you use a BR you will need to script your query - active=true^rfc=current.getValue('sys_id')
-Andrew Barnes
Join me at Developer Blog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2019 05:56 AM
This is a variation on a business rule I had used for Problem to resolve related incidents, it should do the trick for you; or at least point you in the direction.
if (current.state.changesTo(3)) {
notifyRelatedIncidents(current);
}
//
// Notify any incidents that are related to the current change
//
function notifyRelatedIncidents(me) {
var incident = new GlideRecord("incident");
incident.addQuery("rfc", "=", me.sys_id);
incident.query();
while (incident.next()) {
if (incident.active == true){
var msg = "Associated change request " + me.number + ' closed with the following close notes.\n' + 'Close Notes:\n' + me.close_notes;
if(incident.state != 6,7){
incident.state.setValue(6);
}
incident.work_notes = msg;
incident.update();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2023 10:09 AM
Hi Tamil5 ,
Try this code in Business Rule and take Change request table and in the condition make sure state would be closed.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('rfc=',current.sys_id);
gr.query();
while(gr.next()){
if(gr.active == true){
gr.state = '7';
gr.close_notes = "resolved by caller";
gr.close_code = "known error";
gr.update();
}
}
})(current, previous);