The Now Platform® Washington DC release is live. Watch now!
09-27-2018 07:11 AM
hi,
Once problem is set to resolved, all the associated incidents should be set to resolved
please help
Solved! Go to Solution.
09-27-2018 07:24 AM
There is an out of the box business rule on the Problem Table. (Maybe they do something different if you start with a newer version, but this is what we have and we've been with SN since the beginning.)
The Business Rule is called: SNC - ITIL - Close Related
Order: 999
Run At Server
When to Run: After
Insert: Checked
Update: Checked
Advanced Script:
if (current.problem_state.changesTo(4)) {
closeRelatedIncidents(current);
closeRelatedTasks(current);
}
//
// Close any incidents that are related to the current problem
//
function closeRelatedIncidents(me) {
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", me.sys_id);
incident.query();
while (incident.next()) {
if ( incident.active == true ){
var msg = "Incident " + incident.number + ' closed based on closure of problem '+me.number;
gs.print(msg);
incident.incident_state.setValue(6);
incident.active.setValue(true);
// incident.comments = msg;
incident.u_resolution = msg;
incident.update();
}
}
incident.close();
}
You may have to change your State Values to correspond to how yours are set up...for us, 4 is "Resolved" on Problem an 6 is "Resolved" on the Incident. We also keep Active = True until our SDAs change the Incident State to Closed...so that is why incident.active.setValue(true);
I hope that's helpful.
Richelle
09-27-2018 07:21 AM
So, there's not a lot to go on here. How are the incidents associated with the problem? If there's a reference field, then you'd set up a business rule for the problem table that fires onUpdate to query all incidents with the sys_id of the problem in whatever field is being used.
Then you'd use a while loop to iterate through the record that were turned up, change their state, and update them.
09-27-2018 07:24 AM
There is an out of the box business rule on the Problem Table. (Maybe they do something different if you start with a newer version, but this is what we have and we've been with SN since the beginning.)
The Business Rule is called: SNC - ITIL - Close Related
Order: 999
Run At Server
When to Run: After
Insert: Checked
Update: Checked
Advanced Script:
if (current.problem_state.changesTo(4)) {
closeRelatedIncidents(current);
closeRelatedTasks(current);
}
//
// Close any incidents that are related to the current problem
//
function closeRelatedIncidents(me) {
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", me.sys_id);
incident.query();
while (incident.next()) {
if ( incident.active == true ){
var msg = "Incident " + incident.number + ' closed based on closure of problem '+me.number;
gs.print(msg);
incident.incident_state.setValue(6);
incident.active.setValue(true);
// incident.comments = msg;
incident.u_resolution = msg;
incident.update();
}
}
incident.close();
}
You may have to change your State Values to correspond to how yours are set up...for us, 4 is "Resolved" on Problem an 6 is "Resolved" on the Incident. We also keep Active = True until our SDAs change the Incident State to Closed...so that is why incident.active.setValue(true);
I hope that's helpful.
Richelle
09-27-2018 07:24 AM
It depends how you've set up your instance but OOB problems don't have close codes which are a mandatory requirement on the incident form. If you automate the closure of all child incidents you'll either have to assign a default close code like 'closed by problem' or leave them without a close code which could affect reporting.
My preference would be to communicate a work around to all child incidents so they are notified that the problem has a solution, close the problem as normal and then the various incident managers can close their incidents with the correct close codes.
If you definitely want to implement this then take a look at the OOB on the incident table that closes child incidents called 'update child incidents' the method is in there, you can adapt it for problem.
EDIT: i stand corrected, there is OOB rules to close related tasks. My views on why not to use them stand though 🙂
07-27-2022 07:54 AM
We just implemented ServiceNow (Rome) in June, 2022. Is there a recommended best practice when closing a Problem ticket? Should all the Incidents "auto close" with a reason code from the Problem ticket? If so, what are the OOB steps to implement?