web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Office365Users.SearchU...
Power Apps
Answered

Office365Users.SearchUserV2 return the full results

(0) ShareShare
ReportReport
Posted on by 201
Hi,

I am trying to return a list of AD Domain synchronised users, using the Office365Users.SearchUserV2 function and are experience some unintended results. I am trying to return a subset of users based on the following criteria:
 
  • Account is enabled
  • The account is not a guest account
  • The company name is "Acme" (substituted for post).
This is the code I am using:
 
ClearCollect(
    colAllUsers,
    Filter(Office365Users.SearchUserV2({isSearchTermRequired:false}).value, CompanyName="Acme" && AccountEnabled = true && !("#EXT#" in UserPrincipalName))
);
 
There should be circa 80 users returned, but I only get back 61. Examining the collection it shows the expected results in alphabetical order - but only up to the letter M.
If I try and widen the search by only including the company name in the search terms, I expect to get back circa 250 users, but only get back 119 - only up to a few entries that start with the letter N.

I have checked some synchronised users outside the returned results and can't see a reason why they would be excluded.
 
Has anyone seen this behaviour before?

Thanks in advance,
Matt
Categories:
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    154,797 Most Valuable Professional on at
    How many users do you have ? The best you can do is search the top 999 like this
    ClearCollect(
        colAllUsers,
        Filter(
      Office365Users.SearchUserV2({isSearchTermRequired: false, top: 999}).value,
      CompanyName = "Acme" && AccountEnabled && !("#EXT#" in UserPrincipalName)
      ) );
    However this may also work for you if your data set is bigger
    ClearCollect(
        colAllUsers,
        Filter(
          Office365Users.SearchUserV2({SearchTerm: "Acme", top: 999}).value, 
          AccountEnabled && !("#EXT#" in UserPrincipalName)
       )
    );

    ​​​​​​​Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Mattpst Profile Picture
    201 on at
    Thanks for suggestion @WarrenBelz, I have circa 330 users, so not hitting the 1000 limit. The second suggest unfortunately returns zero results.

    Kind regards,
    Matt
  • WarrenBelz Profile Picture
    154,797 Most Valuable Professional on at
    Yes - forget the second one - brain not engaged when putting fingers in gear - it will only look at your Search Field.
    Strange though as I ran the first one here and received back the expected result. It is also logical (I cannot think of any other criteria) that if the total (before filtering) Entra User List is under 999, you should get back all results.
    One question I have is are you sure that the CompanyName has been entered on the Entra profile of all relevant users.
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Verified answer
    Mattpst Profile Picture
    201 on at
    I managed to resolve it using the following:
     
    Clear(colAllUsers);
    ForAll(
        Sequence(2),
        With(Office365Users.SearchUserV2({isSearchTermRequired: false,skipToken: Last(colAllUsers).SKIP_TOKEN}) As _user, With({_skipToken: Mid(_user.'@odata.nextLink', Find("skipToken", _user.'@odata.nextLink') + 10)},
                Collect(colAllUsers, AddColumns(_user.value, SKIP_TOKEN, _skipToken));
            )
        )
    );
    This returned all my users and I was then able to filter the collection using:
     
    ClearCollect(colAcmeUsers, Filter(colAllUsers, CompanyName="Acme" && AccountEnabled=true && !("#EXT#" in UserPrincipalName)));
     
  • WarrenBelz Profile Picture
    154,797 Most Valuable Professional on at
    Sounds to me that you have more than 999 users in the full Entra list (which was what I suspected from the start) - you would not need all of that if the total was under 999.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard