Incident should not get resolved until all incident tasks associated with it gets closed

Shraddha desai
Tera Contributor

Incident should not get resolved until all incident tasks associated with it gets closed.

How to do this?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use Before update BR on incident table

Condition: State [Changes to] Resolved

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var inc = current.getUniqueValue();
	var gr = new GlideRecord("incident_task");
	gr.addActiveQuery();
	gr.addQuery("incident", inc).addOrCondition("parent", inc);
	gr.setLimit(1);
	gr.query();
	if (gr.hasNext()) {
		gs.addErrorMessage("Please close incident task before resolving incident");
		current.setAbortAction(true);
	}

})(current, previous);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

@Shraddha desai 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Thank you for code and it is working good for me. However I am facing 1 issue here that error message getting displayed on screen is only for few second and it is getting disappeared (I want it to be displayed). Do you have any clue why it is happening. I checked similar BR, tried with condition change, looked into UI policy and I could not suspect anything.

Can you please help here?

@Yashashri 

the error message will disappear after sometime based on system property, it won't stay for long

that's platform behavior.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader