cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

Re: Getting multiple user IDs from Microsoft teams shifts

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
Highlighted
Dual Super User
Dual Super User

Re: Getting multiple user IDs from Microsoft teams shifts

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.
Highlighted
Community Support
Community Support

Re: Getting multiple user IDs from Microsoft teams shifts

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

Highlighted
Helper I
Helper I

Re: Getting multiple user IDs from Microsoft teams shifts

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
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (11,119)