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:
- the looked up user's job title
- the looked up user's manager
- the looked up user's manager's job title
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!