web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Validating if a list o...
Power Automate
Unanswered

Validating if a list of users are part of a group, if not, then add them.

(0) ShareShare
ReportReport
Posted on by 50

Hello, community, I have the following issue I was hoping you could help me with:

 

I am able to verify if a single user is part of a Group 1, if he is not, then add the user to the Group 1. If the user is part of group 1, then add to Group 2. This flow works fine:

Flow 1.png

 

What I am not able, is to verify a list of users; the issue I have is that when the first user is evaluated, the flow uses that same evaluation of the first user for all the rest. Here is the flow I need your support with: 

 

Flow 2.png

 

 

In advance thanks for your support.

 

Find me in LinkedIn https://www.linkedin.com/in/oscarmartinezv/

 

Regards,

 

Oscar

 

 

Categories:
I have the same question (0)
  • efialttes Profile Picture
    14,756 on at
    Re: Validating if a list of users are part of a group, if not, then add them.

    Hola Oscar!

    Are you currently filtering the results of 'Get group members' to get only results matching the email from current Apply to each iteration?

    If so, can you share the expression you are using for filtering purposes?

    If not, I think you need it to do it

    Thanx!

  • Oscar_Valerock Profile Picture
    50 on at
    Re: Validating if a list of users are part of a group, if not, then add them.

    Hola @efialttes ,

    No, I am not filtering the results, can you tell me how to do this?

    Regards,

    Oscar

  • efialttes Profile Picture
    14,756 on at
    Re: Validating if a list of users are part of a group, if not, then add them.

    Hola de nuevo!

    JUst reviewing your flow, not clear to me the purpose of variable called 'Variable' in which you assigned the expression:

    int(length(body('Get_group_members')?['Value']

    If you do not apply any filter, this expression provides you the nr of members on this group.

     

    I mean, I assume the Group you are asking for will probably have more than 1 member, its nr of members will not be dependant on the email address you are currently iterating.

     

    I thought your goal was:

    Get group member filtering with the email address you are currently iterating. So this would lead to:

    1 match -> false branch in your current condition

    0 matches-> true branch in your condition

     

    Is my assumption correct?

    Thanx!

     

     

  • Oscar_Valerock Profile Picture
    50 on at
    Re: Validating if a list of users are part of a group, if not, then add them.

    Hola @efialttes ,

     

    I was expecting that the function evaluates if the member was on the list or not. I have done some tests and you are right, is evaluating the number of members which is not useful.

     

    Your assumption is correct, I need to evaluate if every member of the list is in the group or not. Any hint on how to solve this?

     

    Muchas gracias por el tiempo y la ayuda.

     

    Oscar

  • efialttes Profile Picture
    14,756 on at
    Re: Validating if a list of users are part of a group, if not, then add them.

    Hola!
    My suggestion is to add a Filter array action block to your design. Assign as its input the output of 'Get group members' and evaluate inside if email from current Filter Array iteration equals to email from current Apply to Each iteration.
    Then on your condition you can evaluate if Filter Array output length is greater than zero
    Please have a try and let us know

  • Verified answer
    efialttes Profile Picture
    14,756 on at
    Re: Validating if a list of users are part of a group, if not, then add them.

    Hi again!

    I you did not get used to  'Filter array' action block yet, here you are the official documentation from Microsoft:

    https://docs.microsoft.com/en-us/power-automate/data-operations#use-the-filter-array-action

     

    Sorry I do not have permissions to access Azure AD connector 😞

    So I will add the Filter array Screenshot from the previous link instead

    Flow_FilterArrayADD.png

    1.- 'Get group members' output

    2.- assign email field 'Get list members' output (current Filter array input)

    3.- select 'equals' operator

    4.- assign email field from current Apply To Each input

     

    So your Filter array output will be also an array, with as many elements as list members matching the email address. Ideally, either 0 or 1 element.

     

    And now, the condition to evaluate nr of elements from Filter Array Output

    Flow_FilterArrayADD_2.png

    Hope this helps

  • Verified answer
    Oscar_Valerock Profile Picture
    50 on at
    Re: Validating if a list of users are part of a group, if not, then add them.

    @efialttes 

     

    Your approach solves perfectly the issue, thanks for the time.

     

    in the meantime, I found a different flow that also does the work and I leave below in case anyone else needs it.

     

    Flow 3.png

     

  • efialttes Profile Picture
    14,756 on at
    Re: Validating if a list of users are part of a group, if not, then add them.

    Thanx for sharing the tip, Oscar! I have marked it also as a solution, sure it will help others in the future

    You guys make this community great!

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard