I have an app that gets the user's manager for approvals. If no manager is returned the user can search users and set a manager manually.
First I get the employee's AD record using Office365.SearchUserV2
// set default employee
Set(
varDefaultUser,
First(
Office365Users.SearchUserV2(
{
searchTerm: Trim(User().Email),
top: 1
}
).value
)
);
Then I use the user's Id to get the Manager
// set manager
If(
!IsBlank(varDefaultUser.Id),
Set(
varDefaultManager,
Office365Users.Manager(varDefaultUser.Id)
)
);
If the user doesn't have a manager set in AD I get errors. I've switched on formula level error management to suppress the Power Apps errors to the user, but still getting errors using the app with a user without a manager.
This function would be better if it returned false when the user has no manager instead throwing errors. Is there a way I can test for error and take an alternate action and avoid displaying errors to the user? If the user doesn't have a manager i.e. varDefaultManager is blank then I display a people picker for them to select their own approver.

Report
All responses (
Answers (