cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Oscar_Valerock
Frequent Visitor

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

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

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

@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

 

View solution in original post

8 REPLIES 8
efialttes
Super User
Super User

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!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Hola @efialttes ,

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

Regards,

Oscar

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!

 

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



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

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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

@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

 

View solution in original post

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!

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,442)