Hi
I am customising a SharePoint form using PowerApps. The column Requester Name is of type Person / Group, users can look up users in Azure AD. Based on this field other fields are populated and written to the SharePoint list on submit, including:
Sometimes, the selected user will not have some or all of the above properties.
This is the code I have written:
Default property on Manager Name DataCardValue
If(
!IsEmpty(DataCardValue15.Selected),
Office365Users.ManagerV2(DataCardValue15.Selected.Email).displayName
)
Similar code is executed on the Text and Default property on the DataCardValues of Requester Title and Manager Title.
What I was expecting:
If a user is selected in Requester Name, return and display information about them/their manager.
What actually happened:
Scenario 1
A user has not been selected, the following error message is displayed:
Office365Users.UserProfileV2 failed: The method 'UserProfileV2' has an invalid value for parameter 'id'
I am not sure why this is happening since the condition of a user being selected is not being met, therefore the second part should not run.
Scenario 2
A user has been selected but the AD object is missing some information and is displaying the below error:
Office365Users.ManagerV2 failed: {
"error": {
"code": "Request_ResourceNotFound",
"message": "Resource 'manager' does not exist or one of its queried reference-property objects are not present.",
"innerError": {
"request-id": "20a0f2e1-52e7-4e83-a1e8-6b13dfdc09c5",
"date": "2019-11-28T04:54:33"
}
}
}
I am not catching this error, so this is okay. Does anyone know of a way to catch this error?
How do I return information about a user that is selected dynamically and how do I handle errors if no/the wrong information is returned? Am I on the right track here? Any help would be appreciated!
Very good ! Solved it for me
I've been researching this issue for months and your solution worked for me! The feature is now in upcoming Features and out of Experimental, but it did the trick!! I was trying to use manager in a gallery for a staff directory and now, no errors!! Thanks so much.
I think you could be partially right about the error being because of an empty manager, but I received the error even if the user I entered (me, as
User().Email
) had a manager. So I think it appeared because I was mixing "Manager" & "ManagerV2". I had the right case for the properties I was using ("Manager" requires capitals for the property names, "ManagerV2" requires lowercase), but it didn't matter - I think it got hung up because I filled with a combination of them instead of strictly just using one or the other. Here is the one with the error:
If(SharePointForm1.Mode=FormMode.New && Not( gvCurrentManager.userPrincipalName = ""),{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
DisplayName: Office365Users.ManagerV2(User().Email).displayName,
Claims: "i:0#.f|membership|" & Lower(Office365Users.ManagerV2(User().Email).mail),
Department: "",
Email: Office365Users.Manager(User().Email).Mail
},Parent.Default)
where gvCurrentManager was filled with
Office365Users.ManagerV2(DataCardValue2.Selected.Email)
Instead of this combination, where it worked and I got rid of the error:
If(SharePointForm1.Mode=FormMode.New && Not( gvCurrentManager.UserPrincipalName = ""),{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
DisplayName: Office365Users.Manager(User().Email).DisplayName,
Claims: "i:0#.f|membership|" & Lower(Office365Users.Manager(User().Email).Mail),
Department: "",
Email: Office365Users.Manager(User().Email).Mail
},Parent.Default)
and gvCurrentManager was filled with
Office365Users.Manager(DataCardValue2.Selected.Email))
So either something is wrong with "ManagerV2", or you just can't mix the two.
Don't panic!
Simple Enable this:
Go to
«Experimental features section» -> Enable «Formula-level error management»
and Use this Formula: IfError(Office365Users.ManagerV2(User().Email).displayName;"");
was glad to help 😊
Hey @LKS
This seems to be a limitation of Office365 users when a manager does not exist for the employee. The data in AAD needs to be correct and appropriate for all the users to work with this case. Though you can apply some kind of exclusion for employees who do not have managers like: https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Office365Users-Manager-throws-error-when-CEO-has-no-manager/td-p/36183
While to make this work for the employees that have manager details stored, please update the default property of the data-cards as:
Employee Title:
If(
!IsEmpty(DataCardValue15.Selected),
Office365Users.UserProfileV2(DataCardValue15.Selected.Email).jobTitle
)
Manager Name:
If(
!IsBlank(DataCardValue15.Selected.Email),Office365Users.ManagerV2(DataCardValue15.Selected.Email).displayName)
Manager Title:
If(
!IsBlank(DataCardValue15.Selected.Email),Office365Users.ManagerV2(DataCardValue15.Selected.Email).jobTitle)
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473