cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
trush
Frequent Visitor

Filtering users to exclude shared and admin accounts - Manager returning error

In my gallery, I only want to list "real users" - so no shared mailboxes, admin accounts etc.  I filter by looking to see if the users have managers, which works OK to exclude the unwanted accounts, except that I get errors logged in the Power Apps interface.  I think that's because the Manager function returns an error (404) when there is no manager.

 

This is my code:

If(!IsBlank(Trim(TextInputSearchUser.Text)),
  Filter(Office365Users.SearchUser({searchTerm:Trim(TextInputSearchUser.Text)}), !IsBlank(Office365Users.Manager(Id))))

 

Should I just accept the errors (they don't appear to the end user I think), or is there a neater way?

 

Thanks

 

T

1 ACCEPTED SOLUTION

Accepted Solutions
trush
Frequent Visitor

I've decided to use the Department property and set that to "None" for the non-person users.  This seems to work well and is not too great a hassle to keep up to date.

 

If(
    !IsBlank(Trim(TextInputSearchUser.Text)),
    Filter(
        Office365Users.SearchUser({searchTerm: Trim(TextInputSearchUser.Text)}),
        !IsMatch(
            Office365Users.UserProfileV2(Id).department,
            "None"
        )
    )
)

 

View solution in original post

6 REPLIES 6
v-jefferni
Community Support
Community Support

Hi @trush ,

 

Could you please share the detail about the error prompts? Is it says “No manager found for the specified user” ?

 

If it is, this is the limitation of the Office365Users Connection (or saying the service). If there is no Manager for the corresponding user ID, then the Office365Users.Manager() function would throw the error.

 

There is already an idea with the status “Under Review”:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Error-handling-inside-PowerApps-Try-Catch/idi-p....

 

On your side, since the users without manager is changing constantly (I suppose), there is no good way to kill the error by far. As it returns correct results, you could accept it and wait for the updates later.

 

Hope it helps.

 

Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution  to help the other members find it.
trush
Frequent Visitor

Yes, it's a 404 that there is no manager.

 

It works in preview, I'll publish it and hopefully all will be ok.

 

I really think that isBlank should cope with errors like this.

 

Many thanks

 

T

trush
Frequent Visitor

So, I have published it and it works fine, but the error message appears on the screen.  Is there any way I can suppress these messages?

trush
Frequent Visitor

I've also modified the code to use the IsBlankorError function to filter out, but that does not suppress the error messages either.  Why would IsError or IsBlankorError not stop errors being raised?

v-jefferni
Community Support
Community Support

Hi @trush ,

 

As I said, this is the limitation of the Office365Users Connection. When a user has no manager, the Office365Users.Manager(UserId) retrieves null value which is not supported in Power Apps, this occurs the error prompt. 

 

If you don't have dynamic list of users who have not been assigned a manager, you could try to assign a solid account such as an Admin as the manager to them, then filter out users with manager not be that account.

 

It is not a good workaround for you since its limitation, but may helpful to other users who may be seeing this.

 

 

Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution  to help the other members find it.
trush
Frequent Visitor

I've decided to use the Department property and set that to "None" for the non-person users.  This seems to work well and is not too great a hassle to keep up to date.

 

If(
    !IsBlank(Trim(TextInputSearchUser.Text)),
    Filter(
        Office365Users.SearchUser({searchTerm: Trim(TextInputSearchUser.Text)}),
        !IsMatch(
            Office365Users.UserProfileV2(Id).department,
            "None"
        )
    )
)

 

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (47,957)