- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 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
4 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
3 hours ago - last edited 3 hours ago
Ideal way to manage this via state transition model. As per your Problem Management process requirements, configure the state transition model and this would work without any code customizations.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB2178948
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
if problem manager and admin are allowed to close then ensure BR doesn't run for them
add this in condition field
!(gs.hasRole('admin') || gs.hasRole('problem_manager'))
Script:
(function executeRule(current, previous /*null when async*/ ) {
var rec = new GlideRecord('problem_task');
rec.addQuery('problem', current.sys_id);
rec.addQuery('active', true);
rec.setLimit(1);
rec.query();
//If any of the tasks are active abort the submission
if (rec.hasNext()) {
gs.addInfoMessage('Submission aborted due to active child tasks.');
current.setAbortAction(true);
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader