Approval state is changing to cancelled automatically

Akshya
Tera Expert

The group approval in my workflow shows cancelled when the approval is completed. I wrote a script where 2 approvals are needed from a group for the approved state.

Below is the script - 

var id;
var approvecount = 0;
var rejectcount = 0;
for (id in groups) {
approvecount = groups[id].approved;
rejectcount = groups[id].rejected;
}
if (approvecount == 2) {
answer = 'approved';
}
if (rejectcount == 1) {

answer = 'rejected';
}

 

The script does work and the "CAB approval notification" does go out and the Approval state does changes to Approved. However, the workflow for Approval-Group shows cancelled and "Approvers" state  in Change Request shows "Cancelled" for the remaining Approvers instead of showing "No longer Required"

Can you explain if there is anything missing or incorrect?

find_real_file.png

 

find_real_file.png

 

Thank you,

Akshya

3 REPLIES 3

HV1
Mega Guru

Workflow activities get cancelled if there are errors or if the workflow ends via a different path.  This usually happens when you have parallel activities defined without using branch-join activities.  I see you branch out to 2 activities after CAB approval. Suggest you to add branch before them and join before the end.  That way you can ensure that workflow ends after all activities have completed. 

Thanks for the feedback. I did add the Branch and and Join to the WF as per your suggestion but it did not work. The Approval Group still shows cancelled. I'm thinking if I need to set the Approval State to "No longer required" for rest of the approvers once the CR has been approved via my script

var id;
var approvecount = 0;
var rejectcount = 0;
for (id in groups) {
approvecount = groups[id].approved; 
rejectcount = groups[id].rejected; 
}
if (approvecount == 2) {
answer = 'approved'; 

if (rejectcount == 1) {

answer = 'rejected'; 
}

 

Do you have any suggestion/feedback?

 

Thanks,

Akshya

The Activity shows that the state does change to "No longer Required" but it immediately changes to "Cancelled"

find_real_file.png