- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2022 11:46 AM
Incident should not get resolved until all incident tasks associated with it gets closed.
How to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2022 08:54 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2022 02:06 PM
Hi, 1 option would be a before BR on state change (Close\Cancel) for the Incident table (or task table) that looks up your related task records and aborts the closure action if any of the sub tasks are still active.
This post appears to be a duplicate of this one
https://community.servicenow.com/community?id=community_question&sys_id=2d46e632db1e0510fd63250913961982
It is not necessary to create multiple threads for 1 question and if anything multiple threads are less likely to produce a clear response\answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2022 08:41 PM
Can you explain in step by step please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2022 08:54 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 08:21 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader