Flow Designer & List Collector "For Each": A low-code solution

Josh Pirozzi
Kilo Sage

 

Purpose: To develop a Catalog Item where end-users can select multiple Records/Options via a List Collector, and Flow Designer is able to differentiate and provide the desired action(s).

 

Background: For our purposes, we wanted to provide a List Collector Variable (referencing our Business Applications Table) where our end-users could select multiple Applications and, based on the selection, certain actions would take place or tasks would generate.

 

NOTE: As of writing this, we are on Vancouver Patch 4. 

 

We had gone through several iterations of development trials/errors in Flow Designer to have our 'If' Statement recognize the differences between CI Records, through creating Flow Actions and MLVS on the Catalog Item, but none would work. The solution will keep you in a Flow (without creating any Actions) and utilizes the newer Function (fx) capability.

 

Some of the notes below are the 'typical' for Catalog Item Flows are created, but I wanted to provide all of the details from the top for full clarity:

 

JoshPirozzi_0-1710160620097.png

 

 

Step 1: Trigger = Service Catalog

  • This is the initial point to trigger the Flow where, when the Catalog Item is submitted, then follow these Steps.

 

Step 2: Get catalog Variables from...

  • Here is where you'll associate the List Collector Variable to your Flow and ensure you can reference it in later Flow Steps.

 

Step 3: Look up the List Collector Records.

  • The key points here are using the 'Look Up Records' to ensure you'll have the data from each/every record selected in the List Collector Variable. 
  • On the 'Look Up Records' step, you'll match up the Conditions where the Record SysID IS ONE OF dot walk from the List Collector Variable Records to the SysID.

JoshPirozzi_0-1710172557362.png

 

Step 4: The 'For Each' Step

  • This will run through each and every Record selected on the List Collector Variable. 
  • On the For Each, you'll select the Records that were looked up in Step 3. 

JoshPirozzi_2-1710161023614.png

 

  • Here is where you'll add the Function onto the captured List Collector Records. To do this:
  • After completing the Records selection, you'll see the Pill View. 
  • On here, hover toward the right-end of the Pill and you'll see an icon for +fx.

JoshPirozzi_4-1710161248024.png

  • Once you've clicked on the +fx, you'll be presented with multiple Function options. Search for Split.

JoshPirozzi_5-1710161297480.png

  • The use of the Split Function will auto-return an Array.String and this is where you can include a Separator. For us, we used a Comma and a space (, ). Add this into the Separator line followed by clicking Apply.

JoshPirozzi_6-1710161391751.png

 

Step 5: The setting of If Statements, Approvals and Tasks

  • Now you'll be able to add the 'If' Statements where/as necessary. While we didn't go through every type of option to see if any other Fields work for this, we confirmed its functionality by Dot-Walking on the 'For Each' Step over to the SysID and a couple of other options on our Business Application CI Record. For the purpose of this example, I'm showing the condition for If the SysID of the selected Record from the List Collector IS the SysID for a Specific CI. 

JoshPirozzi_7-1710161740640.png

 

JoshPirozzi_8-1710161763949.png

 

From here, you should be able to perform the remainder of your Flow, Tasks and Approvals as on any other Flow.

 

I hope this is helpful to those working in Flow Designer and using List Collectors!

Thank you,

Josh Pirozzi

14 REPLIES 14

rafaelalves4337
Tera Contributor

Hey @Josh Pirozzi 

 

Thanks for sharing this, it can help me a lot.

I have a form to add people to servicenow group, so a list collector variable (Sys_user).

Screenshot_189.jpg

The problem is I cannot pass the Flow logic (For each item), it does not allow me to select the "Look up record" record.

 

See image bellow:

Screenshot_188.jpg

 

Any advise on that?

Hi @rafaelalves4337

     For adding Users to Groups, you'll want to use the Group Member (sys_user_grmember) Table. My thought is after the Look Up User Record (Step 2):

  1. Add a Look Up Records Step
    1. Table: sys_user_group
    2. Conditions: sys_id IS sys_id of the Groups selected on the Request
  2. For Each Group
  3. Look up Record
    1. Table: sys_user_grmember
    2. Conditions: sys_id IS sys_id of User
  4. If Group Membership of the User on the Group = 0
  5. Create Record
    1. Table: Sys_user_grmember 
    2. This is to create the Group Member Record on the Group.

Hope this helps!

Josh Pirozzi

rafaelalves4337
Tera Contributor

@Josh Pirozzi ,

 

I dont know why, but my For Each does not accept records, only list.... yours is like this too?

 

Screenshot_190.jpg

Save it and try again. That will sometimes help.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

jitendrag
Tera Expert

Hi @Josh Pirozzi ,

I am kind of stuck with this solution. Can you please help me my flow is getting stuck in for each loop and shows waiting. The approval is sending as well but shows it was evaluated as false.

Please find the attached screen shot.