cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Kingpin
Kudo Kingpin

Text Input used for a search bar, issues with using a variable in the Default property

I have a text input called SearchBox_2. The Default property was automatically set to just "" (empty quotes).

 

I've also got a gallery with the Items property set to
Search(ContactsCollection, SearchBox_2.Text, "cr8e0_contact_name")
This has been working exactly as expected. The records in the gallery change based on what's typed into the text input.

 

However, when I try to make the Default of the text input contain a variable (_searchDefault), nothing shows up in the gallery at all until you type something. Even though _searchDefault is initally set to "", just like the Default property of the text input was originally.

 

I want the default to be a variable because then I can automatically change what's in the results/gallery based on a button my users will click, but they can also type in the search bar and change what's there themseleves, before or after whatever buttons they click. I don't want to hardcode the filter; they need the option to change it. Is there no way to do this? I set _searchDefault on visible of the page, and I've tried

 

Set(_searchDefault, "")
Set(_searchDefault, " ")
Set(_searchDefault, Blank())

 

But no matter what I do, the gallery is completely empty until they type something in. Is there no way to accomplish this? Why does "" work when typed directly into the Default of the text input, but the same value in a variable does not?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User
Dual Super User

Re: Text Input used for a search bar, issues with using a variable in the Default property

Go ahead and set the Default for the search text box to the variable.  Then use an IF statement in your Search like this.

IF(SearchBox_2.Text = _searchDefault,Search(ContactsCollection, _searchDefault, "cr8e0_contact_name"),Search(ContactsCollection, SearchBox_2.Text, "cr8e0_contact_name"))

That will search against the default value wehnever the search box is equal to the default value. This will avoid the problem of having to actually apply the value to the search box through a carriage return to get the filter to re-evaluate.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

2 REPLIES 2
Highlighted
Dual Super User
Dual Super User

Re: Text Input used for a search bar, issues with using a variable in the Default property

Go ahead and set the Default for the search text box to the variable.  Then use an IF statement in your Search like this.

IF(SearchBox_2.Text = _searchDefault,Search(ContactsCollection, _searchDefault, "cr8e0_contact_name"),Search(ContactsCollection, SearchBox_2.Text, "cr8e0_contact_name"))

That will search against the default value wehnever the search box is equal to the default value. This will avoid the problem of having to actually apply the value to the search box through a carriage return to get the filter to re-evaluate.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Text Input used for a search bar, issues with using a variable in the Default property

I actually didn't need to do that at all. It turns out, I just had to close and reopen the app for edit again...

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (8,184)