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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Creating collection of...
Power Apps
Answered

Creating collection of users from Office 365

(0) ShareShare
ReportReport
Posted on by 109

I'm trying to form a collection of users from the "Office 365 Users" connector dependent on their email address. The issue I'm running into is I'm not sure what the second input of my Collect() function should be. I want to be able to add the "whole user" to my collection and not just their display name, email, etc. For example the, the following code produces a collection of just the users display names. 

ForAll(
 Office365Users.SearchUser(),
 If(
 Last(Split(Mail, "@")).Result = "companyEmail.com",
 Collect(users_collection, DisplayName)
 )
)

The problem arises when I want to populate a gallery pulled from this collection and display more than just their name in each cell, such as an email or location. So is there any way to make a collection of the user objects themselves?

Categories:
I have the same question (0)
  • Verified answer
    shoog Profile Picture
    2,164 on at

    To answer your question: replacing DisplayName with ThisRecord will do the trick.

     

    However, I would recommend passing {searchterm: <at> companyname.com} to the searchuser function to prevent having to use ForAll, which is known to be slow with large datasets. You can then just collect the entire output of that function.

  • _sigmaNot_ Profile Picture
    49 on at

    Hi @shoog ,

     

    I'm not able to get this to work.  Does searchterm look in any part of the value or only the beginning?

    Is it possible to add wild cards into the actual searchterm?

    Example:

    Office365Users.SearchUser({searchTerm: "*@mydomain.com"})

     Sorry if this has been answered somewhere else before.  I haven't had luck finding any detailed documentation for the Office365Users connector and it's methods 🙁

  • shoog Profile Picture
    2,164 on at

    It only looks at the beginning, so you would have to use a Filter expression around SearchUser, like this:

    Filter(Office365Users.SearchUserV2({isSearchTermRequired: false}).value, "@mydomain.com" in Mail))
  • _sigmaNot_ Profile Picture
    49 on at

    @shoog - Thanks for getting back to me on this.

     

    I had tried this approach before but unfortunately doesn't work in my case as there's probably close to 100K users in the tenant I'm working with. 

     

    I ended up using PowerAutomate and Azure AD connector to meet my requirements.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard