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

Adding additional Office365Users attributes to a collection

I currently have a page that users can enter search criteria into a text box and a gallery will show all Office365 users that match the criteria.  The gallery has the photo, DisplayName and Department.  I want to modify this gallery so that it only searches Office 365 users that have an email address in a list.

 

I put the list of email addresses into a collection using this:

ClearCollect(collection1,ShowColumns('[dbo].[vw_EmailAddresses]',"email_address"))

 

I tried this under Items for the gallery:

Sort(Filter(Office365Users.SearchUser({searchTerm:"", top:500}), Mail in collection1.email_address),DisplayName))

 

The problem is that this code only searches the first 500 users who are in the email list.  I want it to search all Office365 users and show who are in the list.  If I omit "top:500", then no results are returned.

 

EDIT: Forgot to mention that I want the gallery to be populated when the screen first opens.  Here is the full code I have under Items:

 

If(!IsBlank(txtSearch.Text),
Sort(Filter(Office365Users.SearchUser({searchTerm:txtSearch.Text}),Mail in collection1.email_address),DisplayName)
,Sort(Filter(Office365Users.SearchUser({searchTerm:"", top:500}), Mail in collection1.email_address),DisplayName)
)

1 REPLY 1
Community Support
Community Support

Hi @sjlee ,

The reason why you met this problem is that:

In default, the Office365.SearchUser() function could only retrieve 100 records.

So if you do not add "top:500" in your formula, the Office365.SearchUser()  function only returns result of 100 records and  the related records are not the top 100.

Here's a similar issue for your reference:

https://powerusers.microsoft.com/t5/Expressions-and-Formulas/Office365Users-SearchUser-only-returnin...

 

Secondly, if you want gallery to be populated when the screen first opens, I suggest you set the clearcollect formula to the screen's OnVisible property.Then, when you loads this screen, the collection will automatically populate, the items in the gallery will also display.

 

 

Best regards,

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (12,972)