cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PremierD
Helper II
Helper II

New 365 group member then create a SharePoint folder

Hi PA community,

I am looking for some advise that I do not even know if it is possible. Not even sure where to start with the flow as I have had a look and could not find the answer, so here goes. 

Lets say I have a 365 group called 'staff' and then a SharePoint document library. Is there anyway that when new user 'a' is added to the group 'staff' it can create a folder for them in the SharePoint site?

 

Does anyone know if it is possible, the group will always stay the same. Thanks in advance. 

1 ACCEPTED SOLUTION

Accepted Solutions
fchopo
Super User
Super User

Hello @PremierD 

There is a trigger when a user is added to a group, so it is possible to create the flow you want. Have a look at this example:

HR.png

 

 1) When a new member is added to "Human Resources" group.

 2) If the user is added (removed is false)

2) Get the user profile, using its id.

3) Create a folder on a SharePoint site, in a document library called "Documents".

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

18 REPLIES 18
Pstork1
Dual Super User III
Dual Super User III

I don't think there is a trigger that will fire when you add a new member to a group.  But you could create a recurrence flow that would run periodically (once an hour, once a day, or whatever) and in that flow compare the member list of the group with the folder list.  If a folder doesn't exist create one.  It wouldn't be instantaneous, but it could definitely be done that way.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi Pstork1,

 

Thanks for the quick response, that would be a possible solution. I am very new to PA, would you be able to steer me in the right direction to at least try this method?  

fchopo
Super User
Super User

Hello @PremierD 

There is a trigger when a user is added to a group, so it is possible to create the flow you want. Have a look at this example:

HR.png

 

 1) When a new member is added to "Human Resources" group.

 2) If the user is added (removed is false)

2) Get the user profile, using its id.

3) Create a folder on a SharePoint site, in a document library called "Documents".

 

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

Pstork1
Dual Super User III
Dual Super User III

OK, here's how it works.  Start out with a recurrence flow, get the members of the group, and list of folders in the library, then set a variable to track whether a folder exists or not.

image.png

Next loop through each user.  At the top of that loop set the variable to false, then check each folder and see if it matches the name of the user.  If it does set the variable to true, otherwise do nothing

image.png

after you check each folder check the variable.  If a folder was found for that user then do nothing.  Otherwise create a new folder.

image.png

Be sure that last condition check is inside the main loop, but below the inner loop.

 

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

That is brilliant, thanks very much for the rapid and really helpful response. 

Thanks also, I now have two options and will try both. I am sure they will both come in very handy.

Pstork1
Dual Super User III
Dual Super User III

The trigger is the better solution.  I just didn't remember seeing a trigger for that the last time I looked.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi,

I have tried the flow and unfortunately it fails with the following , would you have any suggestions at all? Thanks

 

failedrun.png

Pstork1
Dual Super User III
Dual Super User III

I looked at the screenshot for the example and @fchopo showed it using the UserId.  That field is actually a GUID.  You should be using the User Principle Name or Email value instead.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi,

Thanks for reply, it only allows User ID, so a bit stuck. I tried adding fields below, but no change. I have removed the fields now.failedrun.png

Pstork1
Dual Super User III
Dual Super User III

The problem is that the trigger only returns the GUID (UserID) for the user and you can't use that in Get User Profile.  So you'll need to add a call to Azure AD to Get the user details using the UserID.  That may be all you need since that will return the Display Name for the user.  Otherwise you can then make a call to get the Profile based on the UPN returned from Azure AD.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hello

@Pstork1 is right, as I didn't realize that to get the user profile you need its UPN, and not its ID.

Try it and let us know.

Regards,

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

Hi Both,

I tried in my limited knowledge to do as advised and I still get the same result. If someone could tell me what I may be doing wrong that would be really appreciated.

azure.png

azure 2.png

 

Thanks

Pstork1
Dual Super User III
Dual Super User III

According to the error the problem is that the flow never executes the Get User.  What does the condition that leads to the Yes branch look like?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi,

Thanks for the response, here is the whole flow. 

 

layout.png

Pstork1
Dual Super User III
Dual Super User III

The problem with the condition is that @Removed doesn't exist if a user is added to the group.  So your condition fails because @Removed does not equal false.  It doesn't exist.  Try this condition instead.  It tests to make sure that 

@Removed is null and that UserID is not.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

That worked brilliantly , thanks! Now I have another issue. Instead of being a 365 group I need it to work on a security group. Is that possible? Sorry for all the questions and I really appreciate all the help. 

Pstork1
Dual Super User III
Dual Super User III

Now we are back to my original reply.  Azure AD doesn't have a trigger that fires when a new user is added to a group.  So you would have to use a recurrence trigger and check the group each time for new users.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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.

Users online (3,406)