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

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.

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (2,052)