Change Task closing if Change Request is closed

Steven Parker
Giga Sage

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?

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron

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.

View solution in original post

3 REPLIES 3

Ahmmed Ali
Giga Sage

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

Jaspal Singh
Mega Patron

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.

Thanks! Works great