- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 08:22 AM
When Change request was closed ,automatically associated incidents also closed?
Scenario: We want closed incidents automatically, associated with Change request. When change request closed.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 08:26 AM
HI RAM,
This is a variation on a business rule 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 my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 08:26 AM
assuming you have made a relationship to the incident table, with a field in the incident identifying the change
var gr = new GlideRecord("incident");
gr.addQuery("change", current.sys_id);
gr.query();
while (gr.next()) {
gr.state= 'x' ; //where x is the value of the state you want the incident in as you may want resolved or closed.
gr.update();
}