cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
unslog
New Member

List all employees gallery - employee directory

 

Hi,

 

I'm new to Power apps, and using the native Power Apps "People screen" to create a Employee Directory .

people.JPG

Is it possible to have the default view to list all members of staff who have a mobile number, if the TextSearchBox is blank?

 

e.g. Current when the TextSearchBox is blank, I would ideally like to list all employees in this view, and once the user starts typing will it start filtering the gallery view.

 employee directory.JPG

 

 

I have tried various things but for the life of me cannot figure out how to have the gallery populated with user on page load.

 

The code linked to the gallery is 

  

 

 Filter(Office365Users.SearchUser({searchTerm: If(TextSearchBox3.Text = "","*",TextSearchBox3.Text)}),!IsBlank(mobilePhone)) 

 

 

This code works perfectly to filter only employees which with a mobile number, so still want that functionality...however ideally want the screen to be populated with all users with a mobile number on page load.

 

Hope this makes sense 🙂

 

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @unslog :

Pleaset set UserBrowseGallery's Items proeprty to:

If(
 !IsBlank(Trim(TextSearchBox3.Text)),
 Filter(Office365Users.SearchUser({searchTerm: Trim(TextSearchBox3.Text), top: 15}),!IsBlank(mobilePhone)),
 Filter(Office365Users.SearchUser({top:500}),!IsBlank(mobilePhone))  
)

Best Regards,

Bof

View solution in original post

4 REPLIES 4
v-bofeng-msft
Community Support
Community Support

Hi @unslog :

Firstly,let me explain why your encounted this problem.

This is related to the Visible property of UserBrowseGallery1.It is set by default to

 

! IsBlank(Trim(TextSearchBox1.Text))

 

.So when there is no value in TextSearchBox1, you will not see any value in this gallery anyway.

Secondly,please try:

1\Set the UserBrowseGallery1's Visible property to:

 

true

 

2\Set the UserBrowseGallery1's Items property to:

 

If(
 !IsBlank(Trim(TextSearchBox1.Text)),
 Office365Users.SearchUser({searchTerm: Trim(TextSearchBox1.Text), top: 15}),
 Filter(Office365Users.SearchUser({searchTerm: If(TextSearchBox3.Text = "","*",TextSearchBox3.Text)}),!IsBlank(mobilePhone))  
)

 

Best Regards,

Bof

@v-bofeng-msft 

 

Many thanks for replying...I tried your suggestion however the full directory isn't visible on page load. I'm I updating this correctly? see screenshots.

usergallery.JPG

visible.JPG

Hi @unslog :

Pleaset set UserBrowseGallery's Items proeprty to:

If(
 !IsBlank(Trim(TextSearchBox3.Text)),
 Filter(Office365Users.SearchUser({searchTerm: Trim(TextSearchBox3.Text), top: 15}),!IsBlank(mobilePhone)),
 Filter(Office365Users.SearchUser({top:500}),!IsBlank(mobilePhone))  
)

Best Regards,

Bof

Hi, 

 

Sorry to go off topic, but thought I could use existing thread for others to follow.

 

In addition to the TextBox search, can I introduce a Department dropdown, so the user can search by User "OR" by department. So basically a Textbox and a dropdown to control the output of a single gallery

 

I have managed to populate the dropdown box with distinct "department" values using this code

 

Distinct(ShowColumns(Filter(Office365Users.SearchUser({top:500}),!IsBlank(mobilePhone)),"Department"),Department)

 

The challenge is to link this dropdown to the existing gallery filter. I was thinking a OR operand could do this, but proving tricky to get the syntax right

 

Here  is one example I tried to incorporate from another post But no  go 😞 Is this possible?

SortByColumns(If(
 !IsBlank(Trim(TextSearchBox3.Text)),
  
If(Dropdown4.selected.Value="", Filter(Office365Users.SearchUser({searchTerm: Trim(TextSearchBox3.Text), top: 15}),!IsBlank(mobilePhone)), 

Filter(Office365Users.SearchUser({searchTerm:"",top:500}),Department = Dropdown4.Selected.Department)),

 Filter(Office365Users.SearchUser({top:500}),!IsBlank(mobilePhone))
),"Department",Ascending,"UserPrincipalName",Ascending)

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,097)