How to cancelled Approval group activity using wait for condition based on script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2022 11:37 PM
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.
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2022 11:49 PM - edited 10-23-2022 11:49 PM
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. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2022 09:12 PM
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.
Thanks,
Minal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2022 09:27 PM
Could you please paste the screenshot of the logs? Just want to see what values are there in those variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2022 09:44 PM
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.
Thanks.