How to cancelled Approval group activity using wait for condition based on script

Minal7
Tera Contributor

I have added cancelled condition in the Approval group activity and I have cancelled the approval through the scheduled job but the approval takes approve and the next activity is run.

Minal7_0-1666593173696.png

 

so i need to script for cancelling the Approval group activity.

I have try to below code but it is not work

if (counts.approved != 0) {

answer = 'approved';

} else if (counts.rejected =! 0) {

answer = 'rejected';

} else if (counts.cancelled !=0) {

answer = 'cancelled';

}

Thanks for any help.

8 REPLIES 8

H_9
Giga Guru

Hello,

Line no 3 in your code looks incorrect, "} else if (counts.rejected =! 0) {"

Please correct it as follows:

"} else if (counts.rejected != 0) {"

Also, 

Before line #1 in your script, put following

gs.info('Approvals Check  Approved: '+ counts.approved);

gs.info('Approvals Check  Rejected: '+ counts.rejected);

gs.info('Approvals Check  Cancelled: '+ counts.cancelled);

 

And check in the logs once you run the workflow again. This will give your better insights of what is returning in these variables and whether your comparison is correct or not.

 

Please mark the answer correct if it helps. 🙂

Thanks. 🙂

Minal7
Tera Contributor

Hello Giga

Thanks for the solution, for me it is not working  I have updated the given answer. All approval are cancelled but Workflow is stuck in the same activity. 

Minal7_0-1666671014257.png

 

Thanks,

Minal

Could you please paste the screenshot of the logs? Just want to see what values are there in those variables.

Thanks. 🙂

Minal7
Tera Contributor

Hello

Logs values are not there because the approval group activity is not completed.

Please see the below screenshot, all approvals are cancelled but in the group approval it is showing requested.

Minal7_0-1666672611442.png

Minal7_1-1666672666065.png

Thanks.