cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kadd
Resolver III
Resolver III

Updating multi-people field by removing users from multi-people field

Hello,

 

Hope you are all well.

 

i created a list to manage the users of my sharepoint site. I have a workflow to create SP Groups and add users to it and i have another workflow to remove users from the SP Group.

 

Users are stored in a list in a multi-People field call "Users" and users i want to remove are stored in a multi-people field called "PeopleToBeRemoved". Each item corresponds to a SPGroup and has it's users and it's ...people to be removed.

 

What i'm trying to do is...if i put one or several users in "PeopleToBeRemoved", they should be removed from the SPGroup (this works) but also be removed from the field "Users".

 

I manage to make it work when i put one user one by one in field "PeopleToBeRemoved". the flow fires, compares the users "PeopleToBeRemoved" one by one with the users in "Users" one by one. but when i try to remove several users. it removes the first one and updates the "Users" list accordingly...then as of the second one, it removes the second correctly from the SPGroup but doesn't update the "Users" field anymore.

 

I use variable that i initialise (varUsersArray with the value of Users and varUsersIntermediate that appends the users)

 

so for each "PeopleToBeremoved" , it compares Users Email and PeopleToBeRemoved Email. if they are different, it populates varUsersIntermediate

 

2021-03-14 14_59_46-Edit your flow _ Power Automate.png

 

Then it assigns varUsersIntermediate to varUsersArray and  updates the field "Users" with varUsersArray.... which is reused in the users loop to go through the users.

 

2021-03-14 15_00_33-Edit your flow _ Power Automate.png

 

At the second pass, it seems that it considers Users email always equal to PeopleToBeRemoved email...whatever the values of the users....so it never repopulated varUsersIntermediate and never updates the field "Users" anymore.

 

could someone, please, be able to help me on this ?

 

I also tried to do this with a Filter Array action but i didn't manage, i guess, cause when i never have the possibility to get the "output" attribute to put it in my update action , the dynamic values only show me "Current Item"

 

2021-03-14 15_32_25-Edit your flow _ Power Automate.png

 

 

Voila ! hope someone can help .

 

Thanks a lot !!

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi!

It's not you the stupid one here, it's just me, sundays, hungovers and my English 😄

 

Well, I found out a way to do it, at's extremely complex so I assume there must be a cleaner simpler way to achieve your requirements. But, in the meantime...

 

My starting point is a 'Get item', not sure if in your case it's a trigger, or even a 'List items', but anyway, the overall design is here:

Flow_Multiperson_02.png

 

The logic just before 'Apply to each' is as follows

Flow_Multiperson_03.png

 

Now, the tricky part is inside 'Apply to each'. I iterate all over 'PeopleToBeRemoved' array, added an auxiliary 'Compose' action block to reshape the item under evaluation in each iteration, and added a Condition action block just to ensure each person to be removed is already a user

Flow_Multiperson_04.png

...so the condition checks if item from current iteration is part of the Users array...

Flow_Multiperson_05.png

Now on the true branch, I added a 'Scope' that should internally deal with the permissions removal from item currently iterated, next I focus on prepare for updating Users related info

Flow_Multiperson_06.png

Same approach followed to prepare for update PeopleToBeRemoved related info

Flow_Multiperson_07.png

Last step, update the SP item:

Flow_Multiperson_08.png

I just did a test with two persons to be removed, it worked like a charm

Please give it a try and let us know your progress

 



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

6 REPLIES 6
efialttes
Super User
Super User

Hi!

So I understand that when you mention ...'Users are stored in a list in a multi-People field call "Users" and users i want to remove are stored in a multi-people field called "PeopleToBeRemoved"...'

You mena some sort of structure like this one, right?

Flow_Multiperson_01.png

If my assumption is correct, what's the challenge? Trying to figure out if one or more users added on 'people to be removed' field already exist in 'Users' field? And if so remove each of the users matching from both fields?

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!



Kadd
Resolver III
Resolver III

Hi @efialttes ,

 

yes the screenshot is correct.

 

well, the way you say it , it seems that you know how to do and i'm a bt stupid cause i can't manage 😄 .. but yes, it's exactly that ! removing the users in PeopleToBeRemoved from both fields.

 

Thanks 🙂

 

Hi!

It's not you the stupid one here, it's just me, sundays, hungovers and my English 😄

 

Well, I found out a way to do it, at's extremely complex so I assume there must be a cleaner simpler way to achieve your requirements. But, in the meantime...

 

My starting point is a 'Get item', not sure if in your case it's a trigger, or even a 'List items', but anyway, the overall design is here:

Flow_Multiperson_02.png

 

The logic just before 'Apply to each' is as follows

Flow_Multiperson_03.png

 

Now, the tricky part is inside 'Apply to each'. I iterate all over 'PeopleToBeRemoved' array, added an auxiliary 'Compose' action block to reshape the item under evaluation in each iteration, and added a Condition action block just to ensure each person to be removed is already a user

Flow_Multiperson_04.png

...so the condition checks if item from current iteration is part of the Users array...

Flow_Multiperson_05.png

Now on the true branch, I added a 'Scope' that should internally deal with the permissions removal from item currently iterated, next I focus on prepare for updating Users related info

Flow_Multiperson_06.png

Same approach followed to prepare for update PeopleToBeRemoved related info

Flow_Multiperson_07.png

Last step, update the SP item:

Flow_Multiperson_08.png

I just did a test with two persons to be removed, it worked like a charm

Please give it a try and let us know your progress

 



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 @efialttes ,

 

Thanks a lot for your time spent on this.

 

yes i guess it's pretty complex. i admit i started working on this yesterday afternoon and am trying to figure out how to make it work. i always seem to close to the solution but there's always a little thing that's not working.

 

so i recreated what's on your screenshots but it's not working.

For some reason, in the "Select" actions inside the condition i do not have "Claims" in the dynamic values...i only have the possibility to choose "Outputs"....

 

so the workflow fails at the end cause it tries to put all the attributes of the users into "Users" and "PeopleToBeRemoved" fields  (in the update)

 

hmm...

Kadd
Resolver III
Resolver III

Hello again , @efialttes ,

 

Ok , i readapted a few things and now it works !!! 

 

instead of using the claims in the initialisations, i used the email address

2021-03-14 21_14_45-Edit your flow _ Power Automate.png

 

Same thing in the compose action

2021-03-14 21_18_36-Edit your flow _ Power Automate.png

 

and inside the condition ( i had to remove the Select and readapted this way)

Inked2021-03-14 21_20_06-Edit your flow _ Power Automate_LI.jpg

 

Voila !!!

 

Thanks a lot for your help ‌‌

and ... even on a sunday after a hangover...you're still good 😄

 

Wow, you got the idea fast and your changes make everything look much much better... Thanx for sharing, that's the spirit!

People lile you 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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (4,288)