Workflow transition issues with Change Management Revert to New functionality


Description

Change request is moving forward from "Assess" to the next State of the workflow (i.e., "Authorize" or "Scheduled") when approvals are in Request state and "Revert to New" ui action is used. 

Note: When Ui action has below lines of code to cancel the approvals & restart the workflow 

new WorkflowApprovalUtils().cancelAll(current, comment);
new Workflow().restartWorkflow(current);

 

Expected behaviorWhen "Revert to New" ui action is clicked, as per the script Approvals should changed to 'Cancelled' and workflow should go back to 'New' state 

Actual Behavior: Workflow moves forward with the result 'skipped'. 

Cause

Cancelling approvals does not restart workflows.

By design, cancelWorkflow will set the activity result to skipped which would cause the workflow to move forward before the restartWorkflow is processed.

Resolution

Place "new Workflow().cancel(current)" to stop the workflow first. Then the script will cancel the approvals and restart the workflow as desired.

As shown below:

new Workflow().cancel(current);
new WorkflowApprovalUtils().cancelAll(current, comment);
new Workflow().restartWorkflow(current);