- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
Requirement is to restrict the closure of the problem record if any task is open.
One Business rule i have created but problem manager and problem admin able to close the problem record.
Business Rule:(Update)
When: before
State = Resolved
Script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @jugantanaya,
You can add a role-based check directly in your Business Rule like this:
(function executeRule(current, previous /*null when async*/) {
if (gs.hasRole('problem_manager') || gs.hasRole('problem_admin')) {
var rec = new GlideRecord('problem_task');
rec.addQuery('problem', current.sys_id);
rec.addQuery('active', true);
rec.query();
if (rec.hasNext()) {
gs.addErrorMessage('You cannot resolve or close this Problem because there are still active Problem Tasks.');
current.setAbortAction(true);
}
}
})(current, previous);
This ensures Problem Managers and Admins are also prevented from closing if tasks are still active.
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @jugantanaya,
You can add a role-based check directly in your Business Rule like this:
(function executeRule(current, previous /*null when async*/) {
if (gs.hasRole('problem_manager') || gs.hasRole('problem_admin')) {
var rec = new GlideRecord('problem_task');
rec.addQuery('problem', current.sys_id);
rec.addQuery('active', true);
rec.query();
if (rec.hasNext()) {
gs.addErrorMessage('You cannot resolve or close this Problem because there are still active Problem Tasks.');
current.setAbortAction(true);
}
}
})(current, previous);
This ensures Problem Managers and Admins are also prevented from closing if tasks are still active.
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14m ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
You will have to check the count, because Problem can have multiple tasks and this will just check the
1st task as you are using if. This is not related to role as you mentioned.
Try below:
(function executeRule(current, previous /*null when async*/) {
var rec = new GlideRecord('problem_task');
rec.addQuery('problem', current.sys_id);
rec.addQuery('active', true);
rec.query();
if (rec.getRowCount()>0) {
gs.addInfoMessage('Submission aborted due to active child tasks.');
current.setAbortAction(true);
}
}) (current, previous);
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @jugantanaya ,
Your Business Rule (BR) approach is correct (server-side enforcement is key for reliability), but the issue seems to be in the condition of the rule. It's set to trigger only when State = Resolved , but "closure" often means changing to Closed. If problem managers or admins are updating directly to Closed (skipping Resolved), the rule won't fire, which explains why it works for standard users but not them.
Update the condition to state changes to Closed this triggers specifically when the state is changing to Closed, no matter what it was before.