Auto-closure of all child incidents and it's tasks if parent incident is set to resolved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2022 11:20 PM
For now, the script has been written in way where if any incident is set to resolved where there is open tasks, or if the child incident has open tasks, info message will be shown so that first close the open tasks, and then only you can resolve.
But I want one more feature to be added in it.
We want the auto-closure of all child incidents (incl. open incident tasks of the child incidents) if the PARENT Incident has been set to resolved. The open tasks of a parent incident needs to be closed manually. If someone tries to resolve the parent incident without having the incident_tasks closed before, they will get the Infomessage as a reminder "Unable to close the Incident request as there are open Incident tasks". The same behavior for all other incidents.
Following information should be set when an open task will be closed automatically:
State: Closed Skipped
Work Note in Task: Incident Task was automatically closed due to resolving of Parent Incident.
Please help me on how can I add this new feature into this current BR:
(function executeRule(current, previous /*null when async*/) {
var count = new GlideAggregate('incident_task');
count.addAggregate('COUNT');
count.addQuery("incident",current.sys_id);
count.addActiveQuery();
count.query();
var incidents = 0;
if(count.next())
incidents = count.getAggregate('COUNT');
if ( incidents >0) {
gs.addInfoMessage(gs.getMessage('Unable to close the Incident request as there are open Incident tasks'));
current.state = previous.state;
current.setWorkflow(false);
current.setAbortAction(true);
}
})(current, previous);
Thank You.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 01:10 AM
if any incident is set to resolved where there is open tasks, we cannot resolve until open tasks are closed. We can resolve only when there are no open tasks.
One more feature I want is:
If it is a parent incident, then same functionality should happen, that if it has open tasks, we first need to close them, then we can resolve. But also, when we resolve parent, the child incidents and child incident's open tasks should be auto closed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 01:18 AM
Hi,
I just gave sample script.
Please enhance it as per your requirement.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader