Problem task should be closed before problem record closure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017 11:36 PM
Hi,
In problem management, when I close the problem record the associated problem task should get closed, if not it should throw an error message and abort the action....It is working fine for me but the state changes to closed, throwing an error message and aborting the action but still the state would remains in closed state, when I refresh or go back the state would be in open state (i.e previous state). what should I have to do to make the state field to display the previous value (i.e aborting the action) until I close the problem task record.
Business rule:
Action: Before update
Condition: State changes to closed
Script:
var gr = new GlideRecord('problem_task');
gr.addQuery('active','true');
gr.addQuery('problem',current.sys_id);
gr.query();
if (gr.next()) {
gs.addErrorMessage('Problem cannot be closed before the problem task closure');
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2017 12:11 AM
Hi Asha,
Can you explain your requirement in detail?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2017 12:34 AM
Ankur,
If I close the problem record it should check for the associated problem task, when the problem task record remains in open state while closing the problem record it should throw an error message and abort the action ie the state of problem record should remain in open state.
And for me it is working as expected but when I close the problem record if associated problem task is in open state it is throwing an error message but the state of problem record changes to closed and if I refresh the page,update or go back I can see the state of problem record remain in open state.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2017 12:48 AM
That's the expected behavior, I think your goal is getting fulfill. You do not want to save the state if any of the p_task is open and that's what is happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2017 03:26 AM
Hi Shishir,
Is there any other way to restrict state change to close when an action is aborted?