Hi,
I'm new to Power apps, and using the native Power Apps "People screen" to create a Employee Directory .
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.
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
Solved! Go to Solution.
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 @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
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.
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)
User | Count |
---|---|
261 | |
110 | |
89 | |
53 | |
44 |