- 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 04:55 AM
Hi @Kusuma Sai ,
update your BR as below
and replace your BR script with
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var taskGR = new GlideRecord('incident_task');
taskGR.addQuery('parent', current.sys_id);
taskGR.addQuery('incident', current.sys_id);
taskGR.addActiveQuery();
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 04:58 AM
Hi @Chaitanya ILCR , I have tried the same, but not helping.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 05:13 AM
Hi @Kusuma Sai ,
it should work
did you copy paste the entire script and check?
replace the entire script in the BR with below
I have added try catch if in case of any issue it'll be displayed in the form
(function executeRule(current, previous /*null when async*/ ) {
try {
var taskGR = new GlideRecord('incident_task');
taskGR.addQuery('parent', current.sys_id);
taskGR.addQuery('incident', current.sys_id);
taskGR.addActiveQuery();
taskGR.query();
if (taskGR.hasNext()) {
gs.addErrorMessage('Cannot close the incident while active child tasks exist.');
current.setAbortAction(true);
}
} catch (err) {
gs.addErrorMessage('error occured - ' + err);
}
})(current, previous);
and also please share in details of what's not working if it's working if doesn't work
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 05:38 AM
Can you please suggest
what i have added here ? Incident Task > Incident or Incident Task Parent ?
What I have to do visible "Incident Task Parent"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 05:47 AM - edited 06-13-2025 05:53 AM
Hi @Kusuma Sai
Add both that's should be fine
did you try the script I have shared ?
I have included the both parent and incident fields in the script
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya