- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2018 07:27 AM
So we noticed today that a change request can be closed even if Change Task are still open....it auto closes those task when the Change is closed. I assume there is a business rule doing this.
What is the easiest way to stop this? Basically if there are Change Task still open, we don't want them to be able to close the Change Request...maybe even alert them that "Change tasks are still open, please complete these task then close the Change Request".
Anyone ever done this? A before business rule on Change Request state change? What would be the easiest way to accomplish this?
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2018 07:33 AM
Hi,
You can have a before business rule written that runs on Change Request table when state changes to closed complete/closed skipped etc.
var activeTask = new GlideRecord('change_task');
activeTask.addQuery('active',true);
activeTask.addQuery('change_request', current.sys_id);
activeTask.query();
if (activeTask.next()) {
gs.addErrorMessage('This Change Request has currently opened tasks, and cannot be closed. Please close any open tasks before closing this Requested Item');
current.state = previous.state;
current.setAbortAction(true);
}
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2018 07:33 AM
Hello,
yes, before business rule will be helpful to accomplish this.
query the change task table with current change request number and any task is open, set the abort action true with some error message.
let me know for any further query.
Thanks,
Ali
Thank you,
Ali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2018 07:33 AM
Hi,
You can have a before business rule written that runs on Change Request table when state changes to closed complete/closed skipped etc.
var activeTask = new GlideRecord('change_task');
activeTask.addQuery('active',true);
activeTask.addQuery('change_request', current.sys_id);
activeTask.query();
if (activeTask.next()) {
gs.addErrorMessage('This Change Request has currently opened tasks, and cannot be closed. Please close any open tasks before closing this Requested Item');
current.state = previous.state;
current.setAbortAction(true);
}
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2018 12:35 PM
Thanks! Works great
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven