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!
Solved! Go to Solution.
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,
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.
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,
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
Check out new user group experience and if you are a leader please create your group
Did you miss the call?? Check out the Power Apps Community Call here!
See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
267 | |
225 | |
76 | |
38 | |
37 |
User | Count |
---|---|
339 | |
224 | |
121 | |
71 | |
57 |