Incident tasks state should be resolved, When Incident state changes to Resolved and update Incident task close notes with Incident close notes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 06:13 AM
Incident tasks should be resolved, When Incident state changes to Resolved and update Incident task close notes with Incident close notes.
I'd really appreciate a descriptive walk through on how to solve it.
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 06:28 AM
Hey,
If I understand correctly, you are looking for a solution which resolves a inc task when inc is resolved and close notes for task to be updates as inc close notes.
First things first, there is no resolve state in incident task, if you are looking for one you need to add it, but ideally if we refer to ITSM process, tasks are meant to be closed if you are convinced you have provided the resolution and no pending task is there, so ideally if you are resolving a incident you should keep the task as Work in progress and close the task only when incidents are also closed.
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 06:30 AM
Write an after business rule on the "incident" table and use the condition of state changes to resolved, and then in the script, query the incident task table and update the state and notes. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 06:30 AM
This could probably be done with Flows but I would normally just use a Business Rule for this sort of thing:
And the put the following in the script field on the advanced tab:
(function executeRule(current, previous /*null when async*/) {
var closeText = current.close_notes;
var taskOpenStates = ['1','2','-5']; //These are the values for the incident task state table that should be considered open and need closing
//Find all records in the incident task table linked to your current incident
var grIncTask = new GlideRecord('incident_task');
grIncTask.addQuery('incident', current.getUniqueValue());
grIncTask.addQuery('state','IN',taskOpenStates);
grIncTask.query();
while (grIncTask.next()){
//Loop through all found tasks and closed them
grIncTask.state = '3'; //Closed Complete
grIncTask.close_notes = closeText;
grIncTask.update();
}
})(current, previous);
Please note that the above is untested as we do not use incident tasks but should do the trick based on other tables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 08:37 AM
Hi, this script is not working.