How to prevent users from closing an Incident if there are active Child Tasks?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
how to prevent it using flow????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @MOHAMEDYASA,
there are plenty of options, but a business rule might be the best one.
You can get inspiration from this post
100 % GlideFather experience and 0 % generative AI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @MOHAMEDYASA ,
Servicenow Best Practice : use followings
->Before Update Business Rule
->state changesto closed or resolved
use below script
var childTask= new GlideRecord('incident_task');
childTask.addQuery('parent', current.sys_id);
childTask.addQuery('active', true);
childTask.query();
if (childTask.hasNext()) {
gs.addErrorMessage('You cannot close this Incident because there are active Child Tasks.');
current.setAbortAction(true);
}
Please click on 'Helpful' button if it helped you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
flow will run in backend and not UI side.
You need to add before update business rule so that whenever user tries to close INC it checks Active tasks
Something like this
Before Update: Condition -> State [Change to] Closed
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord("incident_task");
gr.addQuery("parent", current.sys_id).addOrCondition("incident", current.sys_id);
gr.addActiveQuery();
gr.setLimit(1);
gr.query();
if (gr.hasNext()) {
gs.addErrorMessage('You cannot close INC as there is active open incident task');
current.setAbortAction(true);
}
})(current, previous);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader

