Flow Designer - Add one user to multiple groups via variable "List Collector"

Sebastian Pora1
Tera Contributor

Hello Community!

I need to create a simple flow which adds one user to multiple groups selected via a "List Collector" variable in an Catalog Item.
I cant figure out how to achieve this. I already looked up similar questions in the community but couldnt find anything matching.
Also I already tried it with a "for each" action which didnt worked, in addition to that my scripting knowledge is not advanced enough to give that a try.

Feel free to ask any questions if you dont understand my need or if you need further informations.

Thank you in advance!
Sebastian

1 ACCEPTED SOLUTION

OlaN
Giga Sage
Giga Sage

Hi,

I have built a Flow that does precisely that.

Below is a simplified image on how it works, in my flow I have added some logic to first identify if the user already exists as a member in the group, and only if it doesn't exist, I create a group membership record.

find_real_file.png

View solution in original post

4 REPLIES 4

Soeren Maucher
Mega Sage

Hi Sebastian, 

I thought a simple "for each" action in the flow designer should work, but when I tried to reproduce it, I noticed, that somehow I can not access the value in the action (it is greyed out and can not be dragged and dropped). Probably you encountered the same issue.
find_real_file.png
Apparently it is an issue with the list collector, that is not correctly handled by the flow designer. 

However, I found this workaround, which would include some scripting: 
https://community.servicenow.com/community?id=community_blog&sys_id=e244e902dbcc2010fb4ae15b8a9619c3

Besides that, there is another low code approach that I would suggest: Instead of using a List Collector use a "Multi-Row Variable" Set to select the required groups. Regarding the UI it will look differently, but you can definitely loop over this variable type in the flow designer. 
find_real_file.png

Greetings,
Sören

Hi Soren, Can you confirm the field/datapill that you added to for each action is correct. When I tried, I could able to select and iterate through list field. Screenshot attached to the reply for this question.

Vamsi Sreenivas
Giga Guru

Hi @Sebastian Porath , as I was also working on similar requirement I have tried creating the flow and able add a user to multiple groups. Please see the flow action configuration in the below screenshot. 

Please mark my answer as Correct and Helpful if this resolves your issue.

find_real_file.png

 

Regards,

Vamsi S

OlaN
Giga Sage
Giga Sage

Hi,

I have built a Flow that does precisely that.

Below is a simplified image on how it works, in my flow I have added some logic to first identify if the user already exists as a member in the group, and only if it doesn't exist, I create a group membership record.

find_real_file.png