- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 04:46 AM - edited 06-13-2025 04:49 AM
Hi,
If related child 'Incident_task' is Active, prevent the Incident Resolved/Closed.
tried with Before BR and Script Include and OnSubmit CS also, but not working as expected- suggest
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 07:30 AM
Hi @Kusuma Sai ,
Try to use Before Update BR only.
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('incident_task');
gr.addQuery('active','true');
gr.addQuery('incident',current.sys_id);
gr.query();
if (gr.next()) {
gs.addInfoMessage('This Incident cannot be resolved as there is or are active child Incident Tasks. Please close them first');
current.incident_state = previous.incident_state;
current.state = previous.state;
current.setAbortAction(true);
gs.setRedirect(current);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 05:57 AM
@Chaitanya ILCR , yes tried- showing error message but getting error as 'Invaild Update' and state is changing to resolved not preventing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 06:32 AM
Hi @Kusuma Sai ,
that means it's working
just reload the page the state will show the previous value
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 07:43 PM
No not working, State is changing to resolved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 07:30 AM
Hi @Kusuma Sai ,
Try to use Before Update BR only.
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('incident_task');
gr.addQuery('active','true');
gr.addQuery('incident',current.sys_id);
gr.query();
if (gr.next()) {
gs.addInfoMessage('This Incident cannot be resolved as there is or are active child Incident Tasks. Please close them first');
current.incident_state = previous.incident_state;
current.state = previous.state;
current.setAbortAction(true);
gs.setRedirect(current);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 08:20 AM
HI @Kusuma Sai ,
My bad
it was supposed to be Or condition for incident and parent fields
(function executeRule(current, previous /*null when async*/ ) {
var taskGR = new GlideRecord('incident_task');
taskGR.addEncodedQuery('active=true^parent=' + current.sys_id + '^ORincident=' + current.sys_id);
taskGR.query();
if (taskGR.hasNext()) {
gs.addErrorMessage('Cannot close the incident while active child tasks exist.');
current.setAbortAction(true);
}
})(current, previous);
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya