Checking number of users who approved on a group on workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 06:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 06:21 AM
Hi @josephd01 ,
Please try below approach:
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 06:28 AM
Hi,
Thank you for responding. I had no issue when I did this for users alone. But I have a requirement that requires me to use group approval and not user. I was able to get this to work with user approvals. I am just battling to get the group user approvals to work. I double checked the sys_id of the group so my only conclusion is something in my code is not working correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 06:48 AM
Can you share the screenshot of the script where its written? and if there is missing part in script ?
I am not able to understand groups[] declaration which is used in if condition.
Also if this is under approval script of group approval then why 'counts.approved >=5' is not used in IF condition ?
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 11:35 PM
Hi, Please see screenshot
Please see group sys_is :
Please see the comment provided by ServiceNow in the script:
// Set the variable 'answer' to '', 'approved' or 'rejected' to indicate the overall approval status for this approval.
//
// This script is responsible for setting the approval state for each group that is part of this approval activity before
// returning the overall approval state for all of the group(s).
//
// When called, the following variables are available to the script:
//
// Overall for all of the groups that are part of this approval activity:
// counts.total = total number of groups that are part of this approval
// counts.approved = # of groups that approved so far
// counts.rejected = # of groups that rejected so far
// counts.requested = # of groups that are pending approval
// counts.not_requested = # of groups that are not pending approval
// counts.not_required = # of groups that approval is not required
//
// And for each group:
// groups[group_id].total = total number of users that are part of this group's approval
// groups[group_id].approved = # of users that approved so far
// groups[group_id].rejected = # of users that rejected so far
// groups[group_id].requested = # of users that are pending approval
// groups[group_id].not_requested = # of users that are not pending approval
// groups[group_id].not_required = # of users that approval is not required
//
// groups[group_id].approvalIDs[state] = array of user ids that are at the specified approval state
//
// Note: Iterate the groups using:
// for (var id in groups) {
// var group = groups[id];
// ... group.total ...
//