vermaamit16
Kilo Patron

Whenever we are working with a List Collector variable inside the flow designer, we usually encounter an error similar to the error below:

Unable to create serializable iterator for items:a8f98bb0eb32010045e1a5115206fe3a,0a826bf03710200044e0bfc8bcbe5d7a of class: class java.lang.String

 

We get this error because list collector variable is a comma separated string rather than an array, so the 'For Each' action is not able to iterate through that. To remediate this issue, we can follow the approach below:

 

1. Get the List Collector Variable Value from the Catalog Item using Get Catalog Variable Action. Let's assume that we have a list collector variable approvers, and we want to get the list of approvers within our flow to perform some task.

AmitVerma_0-1738662465967.png

2. Convert the List Collector String Variable to an array by using the Split Transformation Function. As the List Collector variable values are separated by Comma, we can split into Comma and convert it to an array. In this case, as the list collector variable references to sys_user table, we will get the sys_id of the users selected in the catalog item.

AmitVerma_1-1738662643054.png

3. Inside the ForEach flow logic, we can now make use of Lookup Record or any other flow action to fulfill the desired action. In this case, we will do a Lookup Record to get the User Record with the help of sys_id and thus use it further as required.

AmitVerma_2-1738662850981.png

 

When we execute this flow, we will get the particular user from the Lookup Record.

 

AmitVerma_3-1738663017302.png

 

Thank you for reading this blog. Please provide your inputs/suggestions if any. Hope you find this article helpful. Don’t forget to Mark it Helpful if it is able to assist you.


Thanks and Regards
Amit Verma

24 Comments
leonard_gilbert
Tera Expert

Worked perfectly and right on time for my use-case.

Vasu2
Tera Contributor

It is returning only the first User in the List collector, not all the list of Users. Can you help on how to get the all the Users in the List Collector Variable

vermaamit16
Kilo Patron

@Vasu2 

 

It is because of the fact that we are iterating the list of users in a for-each flow logic, thus you get only one user at a time. If you want to get all the users, you can make use of a Flow Variable and append the user found within the foreach flow logic. 

 

You can use this flow variable as and when required inside the flow. If you have any specific requirement, let me know so that I could be able to assist you better.

Vasu2
Tera Contributor

In my use case, we have a List Collector variable in the catalog form which is pointing out to User table, once the catalog item is submitted it goes for one Group Approval. once that group approves then the approval should goes to all the List collector users at the same time. Currently the Approval is going one after the other, which means if there are four users, the Approval first goes to first user in the List collector, if Approves then it is going to next user approval.

Please help me where and what to change to send Approvals for all the users at the same time.

Thanks in advance.

 

vermaamit16
Kilo Patron

@Vasu2 

 

Refer below screenshots to get an idea on how you can achieve this -

 

AmitVerma_1-1741594143108.png

 

AmitVerma_2-1741594173398.png

 

AmitVerma_4-1741594402867.png

 

 

// Initialize the approver with the current approver value
var approver = fd_data._4__for_each.item;
// Append the approver to the approverUsers flow variable with a comma
var approverUsers = fd_data.flow_var.approverusers + approver + ','; 
// Return the updated approverUsers
return approverUsers;

AmitVerma_5-1741594439551.png

 

Output :

AmitVerma_6-1741594457155.png

 

 

Vasu2
Tera Contributor

Thanks for the response,

 

1) Somehave I can not able to select the ApproverUsers List in the Ask for Approver step

Vasu2_0-1741828416254.png

2) when I test with a RITM in flow designer, the output of the foreach loop (step before ask for approver) is showing as like below screenshot

Vasu2_1-1741828607796.png

 

vermaamit16
Kilo Patron

@Vasu2 

 

Ensure that you set the flow variable as below and give it a retry:

AmitVerma_0-1741843839795.png

 

kdelbridge
Tera Expert

@vermaamit16 , If I wanted the lookup script to assist me with getting the "name" of the user in the list collector vs the sys_id, what would that script look like? 

 

I have my For Each

kdelbridge_0-1741985762195.png

 

I then built my Lookup User Record 

kdelbridge_0-1741987670944.png

I them am attempting to update the short description using values from the Look Up User Record

 

kdelbridge_0-1741988375236.png

 

It is NOT bringing over the name that I pulled from Node 4 Look Up User Record.

 

kdelbridge_1-1741988575369.png

 

Any ideas? I am still learning, so please be gentle.

 

kdelbridge
Tera Expert

@vermaamit16 , If I wanted the lookup script to assist me with getting the "name" of the user in the list collector vs the sys_id, what would that script look like? 

 

I have my For Each

kdelbridge_0-1741985762195.png

 

I then built my Lookup User Record 

kdelbridge_0-1741987670944.png

then attempted to update user record pulling from Node 4

 

kdelbridge_1-1741989877141.png

 

Unfortunately, the name did not pull over on short description as hoped.

 

kdelbridge_2-1741989942196.png

 

Any idea where I may have gone wrong here?

 

Thanks in advance.

 

Vasu2
Tera Contributor

Hi @vermaamit16, It is working now, thanks for the help. 

I am trying to achieve another scenario where in my catalog Item,  I have a List Collector field called 'role' and each role will have single or multiple owners. We can select multiple roles at a time in the List collector. when the catalog item is submitted, it should go to all the role owners approval at a time . If there is multiple Role owners for a role then anyone can Approve or Reject the role. If anyone approve/Reject then we no need another one Approve/Reject for that role. If all the Approvals (Approve/Reject) for the all the selected roles is completed then a task should be open and in that task description all the approved role names should appear. 

Can you help on this flow Logic, Thanks in Advance