Approval Remains cancelled in change and doesn't retrigger

Priyanka Sadhw1
Kilo Expert

Steps:

  1. User raised CR and sent it for approval
  2. Now in assess state if he realize that he forgot to add location, he has option- to move CR to new state(‘Revert to New’). If user moving CR to new, Approval are cancelled.
  3. Now CR is in New state when user can add location and move CR to assess state. Issue is: in assess state as well approval are cancelled, not re-initiating as CR progressing.

 __________________________________________

  1. Once CR is reverted to new- same changes doesn’t reflect in workflowfind_real_file.pngfind_real_file.png

Also old approvals get cancelled.

  1. After I sent CR for approval again after changes, New approval record doesn’t trigger. Ideally it should happen OOTB.
  2. Approver is not notified about cancellation of  approval record and he tried  approving CR and got mail response from system that it is cancelled.
1 ACCEPTED SOLUTION

Chander Bhusha1
Tera Guru

Hi Priyanka,

This is known issue if you instance is prior to Orlando instance. The issue is fixed in Orlando instance. 

If your instance is prior to that version then here are the steps which you need to follow:

You need to update the BR.

Steps:

1. Open the business rule whose name is : Change reverted to New 

Table - change_request.

2.  Update the script in the business rule with the script below:

(function executeRule(current, previous /*null when async*/) {

	// Disassociate approvals
	new ChangeRequestStateHandler(current).disassociateApprovalsFromWorkflow();

	// Set cancelled state on outstanding approvals
	var approvalUtils = new WorkflowApprovalUtils();
	var changeSysId = current.getUniqueValue();
	var statesToCancel = ['requested', 'not requested'];
	var msg = gs.getMessage('This approval record was canceled as a result of the related change request moving back to the {0} state.', current.state.getDisplayValue());
	
	approvalUtils.setUserApprovalsByTask(changeSysId, 'cancelled', msg, statesToCancel);
	approvalUtils.setGroupApprovalsByTask(changeSysId, 'cancelled', msg, statesToCancel);

	// reset approval status
	current.approval = 'not requested';

})(current, previous);

 

Note:  This was update in the BR in Orlando release to re-trigger the approvals when you click on revert to new button.

 

Please mark helpful and correct.

Thanks,

CB

View solution in original post

5 REPLIES 5

Swadesh Saraf2
Kilo Guru

Moving a workflow back in the state is complicated, I would suggest you reattach the workflow.

There is a business rule that comes out of the box named: SNC Approval - Reset conditions - with a section you can configure that will trigger a reset of the workflow and it should attach the new workflow, not just restart the incorrect one.

 

Please look at the business rule, it has ample information to retrigger the workflow. You can add your own required condition there.

Chander Bhusha1
Tera Guru

which version instance you are using currently? 

Chander Bhusha1
Tera Guru

Hi Priyanka,

This is known issue if you instance is prior to Orlando instance. The issue is fixed in Orlando instance. 

If your instance is prior to that version then here are the steps which you need to follow:

You need to update the BR.

Steps:

1. Open the business rule whose name is : Change reverted to New 

Table - change_request.

2.  Update the script in the business rule with the script below:

(function executeRule(current, previous /*null when async*/) {

	// Disassociate approvals
	new ChangeRequestStateHandler(current).disassociateApprovalsFromWorkflow();

	// Set cancelled state on outstanding approvals
	var approvalUtils = new WorkflowApprovalUtils();
	var changeSysId = current.getUniqueValue();
	var statesToCancel = ['requested', 'not requested'];
	var msg = gs.getMessage('This approval record was canceled as a result of the related change request moving back to the {0} state.', current.state.getDisplayValue());
	
	approvalUtils.setUserApprovalsByTask(changeSysId, 'cancelled', msg, statesToCancel);
	approvalUtils.setGroupApprovalsByTask(changeSysId, 'cancelled', msg, statesToCancel);

	// reset approval status
	current.approval = 'not requested';

})(current, previous);

 

Note:  This was update in the BR in Orlando release to re-trigger the approvals when you click on revert to new button.

 

Please mark helpful and correct.

Thanks,

CB

Hi Chander,

 

As you mentioned the above script is already in instance as OOB.

but the it doesn't working as expected and approval state remains cancelled when reverted to new and not in requested state.

 

is there any changed we should make to see the approval change from cancelled to requested?

 

Best Regards,

Vasu