Incident tasks state should be resolved, When Incident state changes to Resolved and update Incident task close notes with Incident close notes.

Amisha Pattojos
Tera Contributor

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.

4 REPLIES 4

Aman Kumar S
Kilo Patron

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.

 

Best Regards
Aman Kumar

Nayan Mahato
Tera Guru

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.

Joe B2
Giga Guru

This could probably be done with Flows but I would normally just use a Business Rule for this sort of thing:

find_real_file.png

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.

Hi, this script is not working.