Parallel Group Approvals from List Collector in Flow Designer Not Working

LokeshwarRV
Tera Contributor

Hi everyone,

I'm working on a Service Catalog flow in Flow Designer triggered by a Requested Item (sc_req_item). Here i want to get the parallel approavls from the approval groups .I have a List Collector variable called related_services that stores multiple related services (cmdb_ci_service records). Each service has a reference to an approval group in the change_control field.

In my flow, I use a script to collect all the approval group sys_ids from the related services and pass them to the "Ask for Approval" action. Here's the script I'm using:

iam using  a flow variable name ApprovalList with script
var groups = [];
var relatedLists = fd_data._1__get_catalog_variables.related_services;
var serviceGr = new GlideRecord('cmdb_ci_service');
serviceGr.addQuery('sys_id', 'IN', relatedLists);
serviceGr.query();

while (serviceGr.next()) {
    var groupId = serviceGr.getValue('change_control'); // Get sys_id as string
    if (groups.indexOf(groupId) < 0) {
        groups.push(groupId);
    }
}

return groups;

and in Ask for Approval i am setting this
LokeshwarRV_0-1759728354828.png
LokeshwarRV_0-1759728689061.png

 

and i my flow execution i am getting as approval as skipped
Note:Here i want to sent the approval to approval groups parallel

 

Help me to overcome this issue
Thanks in Advance
 
 

 

 
 
 
 
 
 
8 REPLIES 8

@LokeshwarRV 

not very sure then

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Anand2799
Tera Guru

Hi @LokeshwarRV ,

 

I think your flow variable is of type string and you are returning array. 

Update your return statement as:

return groups.join();

 

Thanks

Anand

Hi @Anand2799,

I’m now receiving the group approvals as expected. However, I’ve noticed an issue:
When any one person from any group approves, the system is marking all groups as "no longer required."

This is problematic because we’re aiming for parallel approvals, where at least one person from each group must approve before the process can move forward.

Could you please help check the logic or configuration? Ideally, the workflow should wait for one approval per group, not just any single approval across all groups.

Thanks in advance!

 

Hi @LokeshwarRV ,

 

Parallel approval are always difficult to implement.

 

As you are using dynamic approvals you need to use script for rules, follow the below steps to build out query for rules:

 

From Ask for approval action remove selected value from Approval Field.

for rules select script toggle.

Anand2799_0-1759755811332.png

 

Write below script:

var groups = '287ee6fea9fe198100ada7950d0b1b73,82f0551f535913004e77ddeeff7b12d3,404cedd5930112003b4bb095e57ffbf4';
var rule = '';
if(groups){
    // Approve rule
    var groups_arr = groups.split(',');
//First group
    rule = 'ApprovesRejectsAnyG[' + groups_arr[0] + ']';
//for other groups
    for(var i=1; i<groups_arr.length; i++){
        rule+='&AnyG[' + groups_arr[i] + ']';
    }
    // Reject rule
    rule+='OrRejectsAnyG[' + groups + ']';
}
return rule;

 

Adjust your script as required and refer your variable for groups, my script waits for one user to approve from every group and whenever someone rejects form any of the group it will reject the approval without waiting for any other group.

 

Follow this article for building scripted approvals:

https://www.servicenow.com/community/workflow-automation-blogs/scripted-approvals-in-flow-designer-w...

 

Thanks

Anand