using a List Collector in Flow Designer to set Approvals

EricG2
Tera Guru

I've looked at sever posts like this one on how get the values from a List Collector and use them going forward to populate tasks, tickets, etc..   Very Helpful

 

https://www.servicenow.com/community/developer-blog/using-list-collector-in-flow-designer-for-each-l...

 

Now, with my use case, I'm trying to use a List Collector to assign Badge Access request for different locations.

Typically, users should be only selecting their primary location, so creating 1 approval record was easy.

 

The issue I'm facing is when different locations are selected (E.G. a traveling IT Tech) and multiple approvers are needed.  How would you suggest creating Multiple Approval records at the same time using Flow?

 

With the flow I currently have and using the OOB approval activity, its creating them one at a time and wont create the second until the first is approved/rejected.

 

EricG2_0-1780603238655.png

 

2 REPLIES 2

Sanjay191
Kilo Patron

Hi @EricG2 

 

You can achieve parallel approvals for multiple locations selected in a List Collector by creating a custom Flow Designer Action that dynamically builds an approval rule based on the selected locations and their associated approvers.

Solution Overview

  1. Create a Custom Flow Action
    • Input: List Collector field containing the selected location sys_ids (comma-separated).
    • Output:  approvers_list (String).
  2. Determine Approvers
    • In the Action Script, call a Script Include method (e.g., getApproversList()) that:
      • Accepts the selected location sys_ids.
      • Returns all applicable approval groups and individual approvers for those locations.
      • Returns a JSON response containing:
  3. Build the Approval Rule Dynamically
    • Generate an approval rule string that can be consumed by the Approval Coordinator.
    • This allows ServiceNow to create all approval records simultaneously rather than sequentially.
    •  use the data pill to map the approvers that comes from the custom action.

      please refer the below scriptshots of the flow designer . this will work for you please modify according to your requirement i giving you the reference how we build the solution of it and if anything required please let me know.

      Sanjay191_0-1780662889678.png



      If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
      Thank You




Sanjay191
Kilo Patron

Also please refer  the below custom action script logic 

 var getApproval =  new YOUR_SCRIPT_INCLUDE_NAME().getApproversList(inputs);
 var getting = JSON.parse(getApproval);
 
  var approvalRule="ApprovesAnyG[";
for(var i=0; i<getting.approverGroup.length; i++)
{
 approvalRule+= getting.approverGroup[i]+"]&AnyG[";
}
approvalRule=approvalRule.substr(0,approvalRule.length-6);
  if(getting.approverUser.length != 0)
approvalRule+="&ApprovesAllU["+getting.approverUser+"]OrRejectsAnyG["+getting.approverGroup+"]U["+getting.approverUser+"]";
  else{
    approvalRule+="OrRejectsAnyG["+getting.approverGroup+"]";
  }
 outputs.approvers_list = approvalRule;
  outputs.messages= getting.messages;

makesure write the logic as per your requirement in your script include i giving you reference .
Also makesure t
he generated approval rule would look similar to:

 

ApprovesAnyG[your values]&AnyG[your values]&ApprovesAllU[your values]OrRejectsAnyG[your values,your values]U[your values]

in my senerio i was handling the the single users approver as well group approvals.

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You