Restrict change closure if there are open tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2017 06:08 PM
Hi,
I have coded as per below in an before update BR.
var task=new GlideRecord('Change_Task');
task.addJoinQuery('change', current.number,'change_task.number');
task.query();
while (task.hasnext())
{
if (task.state != 'Closed Complete')
gs.addErrorMessage('Ticket cannot be moved to Closed');
}
But it is not working. Can you help here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 03:14 AM - edited 07-17-2023 03:17 AM
Change Tasks should only be able to be closed if the change state is Implement or Review. else show error message
Before Business rule:
(function executeRule(current, previous /*null when async*/ ) {
gs.addErrorMessage(gs.getMessage('In order to close a change tasks, your Change Request must be in the Implement state '));
current.setAbortAction(true);
gs.setRedirectURL(current);
current.state = previous.state; // it will help us to set previous state after load the form
var changeTask = new GlideRecord('change_task');
if (changeTask.next()) {
changeTask.update();
}
})(current, previous);
I hope this helps. Please mark correct/helpful based on impact