Prevent Problem Task Closure When Associated Change Request Is Not Closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello all,
We encountered an issue where a Problem Task is getting updated to Closed even if the associated Change Request is not in a closed state. The system displayed an error message but still updated the state. To fix this, I tried modifying a Business Rule that checks the related Change Request before allowing the Problem Task to close using the task_rel_task table. However, this approach didn’t work because task_rel_task had no records for the relationship.
How do I check the associated Change Request for a Problem Task from the related list in the most efficient way?
Also Iam attaching few screenshots for your refernce
Your help is very much needed! Any best practices or alternative solutions would be greatly appreciated..
Thank You!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @Akhila P ,
Update your business rule with this script:
(function executeRule(current, previous /*null when async*/ ) {
var isActiveChangeExist = false;
var grChange = new GlideRecord('change_request');
grChange.addQuery('parent', current.getUniqueValue());
grChange.addActiveQuery();
grChange.setLimit(1);
grChange.query();
if (grChange.hasNext()) {
isActiveChangeExist = true;
}
if (isActiveChangeExist) {
gs.addErrorMessage(gs.getMessage("Please close related change request before closing problem task"));
gs.setRedirectURL(current);
current.setAbortAction(true);
}
})(current, previous);
Thanks
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
53m ago
Hello @ Anand2799 ,
I have updated the script with the changes you provided. It is working partially — the error message is appearing as expected, but the state is still updating to Closed.
What other things do I need to add to ensure the state does not change when the error message is displayed?
Thank You,
Akhila
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
39m ago - last edited 37m ago
Can you share some screenshots where you don't want to show Closed state?
Alternatively, you can also create a script include and add it to the UI Action condition, so it will only be available when change request gets completed. However, if you don't want to modify OOB UI Action then BR need to be used.
