cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
knives
Helper I
Helper I

Getting multiple user IDs from Microsoft teams shifts

I am currently in the middle of trying to build a scheduling system within Powerapps that utilises Microsoft teams shifts and the outlook calendar.

 

I am hitting a issue where I can pull out the shifts within a team however that doesn't give me a name of a person, it brings me a user ID. I thought that this would be an easy fix by using the Office365Users connector to collect a user profile and repeat this step for all distinct user ID's.

 

However I keep being met with a "This function cannot be invoked with for all" error. I am so stuck at what to do now as I can't find any other way of pulling team members user id out of teams.

 

Any help or suggestions would be greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @knives ,

Could you please share more details about the error message within your ForAll formula?

Do you want to collect all User Profile of a specific Team Shift?

 

According to the error message that you mentioned, it seems that you use some functions (e.g. Set function, ClearCollect function, etc) that could not be invoked within ForAll function.

 

Based on the issue that you mentioned, I have made a test on my side, please consider take a try with the following formula:

Clear(UserProfiles);
ForAll(
       MicrosoftTeams.ListShifts("Type Specific Team Id Here").value,
       Collect(
               UserProfiles,
               {
                 UserName: Office365Users.UserProfileV2(userId).displayName
               }
       )
)

When you execute above formula, corresponding user name of each Shift assigner under this Team would be saved into the UserProfiles collection.

 

If you want to display distinct user name within your canvas app, you could take a try with above formula:

Distinct(UserProfiles, UserName)

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Pstork1
Dual Super User III
Dual Super User III

You'll have to make sure you have the right permissions for it, but the AzureAD connector can return a user based on the UserID.  I've used it in Flow, so it should operate the same in Power Apps.  You may still have a ForAll problem.  The way to solve that is to feed the array of UserIDs to Power Automate and have it retrieve all the userNames and send them back as a JSON array.



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

Hi @knives ,

Could you please share more details about the error message within your ForAll formula?

Do you want to collect all User Profile of a specific Team Shift?

 

According to the error message that you mentioned, it seems that you use some functions (e.g. Set function, ClearCollect function, etc) that could not be invoked within ForAll function.

 

Based on the issue that you mentioned, I have made a test on my side, please consider take a try with the following formula:

Clear(UserProfiles);
ForAll(
       MicrosoftTeams.ListShifts("Type Specific Team Id Here").value,
       Collect(
               UserProfiles,
               {
                 UserName: Office365Users.UserProfileV2(userId).displayName
               }
       )
)

When you execute above formula, corresponding user name of each Shift assigner under this Team would be saved into the UserProfiles collection.

 

If you want to display distinct user name within your canvas app, you could take a try with above formula:

Distinct(UserProfiles, UserName)

 

Please consider take a try with above solution, check if the issue is solved.

 

Best regards, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thank you that was just the breakthrough that I needed.

 

Just to elaborate on my solution, this is the code that I have finally used:

ClearCollect(Shifts
     ,AddColumns(MicrosoftTeams.ListShifts("Team ID here").value
          ,"Start Time",sharedShift.startDateTime
          ,"End Time",sharedShift.endDateTime
          ,"UserName", Office365Users.UserProfileV2(userId).displayName
     )
)

 

In order to give me each shift in relation to who it is booked on

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
Top Kudoed Authors
Users online (1,823)