Prevent Incident resolution if Open Incident Tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2018 03:39 AM
Hi,
I'm looking for some help with my before Business Rule to prevent an Incident being resolved if there are open Incident Tasks. I've done the following so far:
When to run: Before
Order: 100
Update: Selected
Filter Conditions: 'State' 'changes to' 'Resolved'
This is my script:
(function executeRule(current, previous /*null when async*/) {
var incgr = new GlideRecord('incident_task');
incgr.addActiveQuery();
incgr.addQuery('incident',current.sys_id);
incgr.query();
if (incgr.hasNext()) {
current.setAbortAction(true);
gs.addErrorMessage('All Incident Tasks must be closed before an Incident can be resolved');
action.setRedirectURL(current.sys_id);
}
})(current, previous);
This is finding the open incident tasks and providing the error message. The problem is, it still moves the status to 'Resolved'. Only it hasn't committed this to the DB as if you click 'Reload Form' it moves the state back to what it was previously. So technically, the BR is working but I think it's getting stuck somewhere. I've tried adding current.state = previous.state; to it but that doesn't do anything either.
Am I doing something wrong here? New to ServiceNow so any help would be great. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2018 08:37 AM
What's the goal here? to not allow them to click Resolve button or change state to Resolved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2018 08:45 AM
The resolve button needs to be there, but when they click on it, I need it to show an error message if there are still open Incident Tasks. The state should not change but it's moving to Resolved.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2018 07:31 PM
Then we definitely need to modify the UI action Resolve. Was trying a couple of things, but no luck. Will take some time to work out unless someone else has an idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2018 06:11 AM
I managed to get this working Michael. Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 12:06 AM
I am also facing the same issue. Can you Please help me resolving?