Where a search box exists on 2 separate screens, is it possible to either:
BACKGROUND AND EXPLANATION BELOW:
I have an app connected to a SharePoint list, where users can search for meeting rooms based on the meeting room name (Title) or the room facilities (Equipment). The search box (TextSearchBoxWelcome) is located on the WelcomeScreen, and directs users to BrowseScreenSearch when the Go button is pressed.
WelcomeScreen:
BrowseScreenSearch:
The Items property for the BrowseGallery on BrowseScreenSearch is set to:
SortByColumns(Filter(MeetingRoomsPowerApp, TextSearchBoxWelcome.Text in Title || TextSearchBoxWelcome.Text in Equipment), "Title", If(SortDescending1, Descending, Ascending))
This works great, however I'd like users to then be able to change their search terms using the search box on this screen (TextSearchBoxMain). I believe this should work if I change the Items property to:
If(TextSearchBoxWelcome.Text<>"",SortByColumns(Filter(MeetingRoomsPowerApp, TextSearchBoxWelcome.Text in Title || TextSearchBoxWelcome.Text in Equipment), "Title", If(SortDescending1, Descending, Ascending)),SortByColumns(Filter(MeetingRoomsPowerApp, TextSearchBox1_1.Text in Title || TextSearchBox1_1.Text in Equipment), "Title", If(SortDescending1, Descending, Ascending)))
HOWEVER the problem is that TextSearchBoxWelcome on the WelcomeScreen still contains a value when attempting to search again on the BrowseScreenSearch screen, so new search input doesn't work correctly.
At the moment I've implemented the following workaround:
WelcomeScreen properties:
OnVisible: UpdateContext({resettext: !resettext}); UpdateContext({resettext: !resettext})
TextSearchBoxWelcome properties:
Reset: resettext
HintText: "Search for a room"
GoButton properties:
OnSelect: Navigate(BrowseScreenSearch, Fade) && UpdateContext({TextSearchBoxWelcome:""})
TextSearchBoxMain properties:
OnSelect: Navigate(BrowseScreenFiltered, Fade)
^^^ When the user clicks on the TextSearchBoxMain to perform another search, they are directed to a duplicate Browse Screen (BrowseScreenFiltered) where they can then search the list normally:
The Items property for the BrowseGallery on this screen is set to:
SortByColumns(Filter(MeetingRoomsPowerApp, TextSearchBoxSecondary.Text in Title || TextSearchBoxSecondary.Text in Equipment), "Title", If(SortDescending1, Descending, Ascending))
The problem with this workaround is that the search box loses focus, so even though the user has just clicked on the search box, they are navigated to a new screen and have to click on the search box again.
Is it possible to either:
Thanks in advance!!
Solved! Go to Solution.
Thanks again for your response @v-micsh-msft
I was able to get this working using the Collect and ClearCollect functions, and by setting a default value for the secondary search box. I no longer needed the workaround so I deleted the BrowseScreen Filtered screen and updated the other screens as follows:
WELCOME SCREEN
WelcomeScreen:
OnVisible: UpdateContext({searchReset:true});UpdateContext({searchReset:false})
TextSearchBoxWelcome:
Reset: searchReset
HintText: "Search for a room"
OnChange: false
OnSelect: false
Default: ""
GoButton OnSelect:
ClearCollect(SearchRoom, TextSearchBoxWelcome.Text); If(Len(TextSearchBoxWelcome.Text) > 0, Navigate(BrowseScreenSearch, Fade));Collect(MeetingRoomsPowerApp, TextSearchBoxWelcome.Text); If(Len(TextSearchBoxWelcome.Text) > 0, Navigate(BrowseScreenSearch, Fade))
BROWSE SCREEN SEARCH
TextInputSearchBox properties:
OnChange: false
OnSelect:
Default: First(SearchRoom).Value
Reset: searchReset
HintText: "Search for a room"
SearchButton OnSelect:
If(Len(TextInputSearchBox.Text) > 0, ClearCollect(SearchRoom, TextInputSearchBox.Text), Clear(SearchRoom))
Items property for BrowseGallerySearch:
SortByColumns( Filter(MeetingRoomsPowerApp, TextInputSearchBox.Text in Title || TextInputSearchBox.Text in Equipment), "Title", If(SortDescending1, Descending, Ascending))
DetailScreenButton OnSelect:
ClearCollect(SearchRoom, ThisItem); Collect(PreviousSearchRoom, SearchRoom);Navigate(DetailScreenSearch, Fade)
This method uses 2 collections: SearchRoom and PreviousSearchRoom. I haven't really used collections before, but I was able to dissect the 'Employee Org' powerapp template to get an understanding of what was required.
Hi @starwispy,
Option 1 should be possible.
Please consider change the formula in the following format:
SortByColumns( Filter(MeetingRoomsPowerApp, and(TextSearchBoxWelcome.Text in Title || TextSearchBoxWelcome.Text in Equipment,
TextSearchBox1_1.Text in Title ||
TextSearchBox1_1.Text in Equipment ) ), "Title", If(SortDescending1, Descending, Ascending))
Regards,
Michael
Hi Michael,
That's a much cleaner formula, thank you. Unfortunately without also clearing the value from the WelcomeScreen search box, it only returns results where the item matches both search box values. I'd like for the search on the second screen to replace the original search, rather than act as a secondary filter.
Is there a version of UpdateContext, or a similar parameter, that will work across screens (clearing the search value from the welcome screen search box when a user selects the browse screen search box?
Thanks again for your response @v-micsh-msft
I was able to get this working using the Collect and ClearCollect functions, and by setting a default value for the secondary search box. I no longer needed the workaround so I deleted the BrowseScreen Filtered screen and updated the other screens as follows:
WELCOME SCREEN
WelcomeScreen:
OnVisible: UpdateContext({searchReset:true});UpdateContext({searchReset:false})
TextSearchBoxWelcome:
Reset: searchReset
HintText: "Search for a room"
OnChange: false
OnSelect: false
Default: ""
GoButton OnSelect:
ClearCollect(SearchRoom, TextSearchBoxWelcome.Text); If(Len(TextSearchBoxWelcome.Text) > 0, Navigate(BrowseScreenSearch, Fade));Collect(MeetingRoomsPowerApp, TextSearchBoxWelcome.Text); If(Len(TextSearchBoxWelcome.Text) > 0, Navigate(BrowseScreenSearch, Fade))
BROWSE SCREEN SEARCH
TextInputSearchBox properties:
OnChange: false
OnSelect:
Default: First(SearchRoom).Value
Reset: searchReset
HintText: "Search for a room"
SearchButton OnSelect:
If(Len(TextInputSearchBox.Text) > 0, ClearCollect(SearchRoom, TextInputSearchBox.Text), Clear(SearchRoom))
Items property for BrowseGallerySearch:
SortByColumns( Filter(MeetingRoomsPowerApp, TextInputSearchBox.Text in Title || TextInputSearchBox.Text in Equipment), "Title", If(SortDescending1, Descending, Ascending))
DetailScreenButton OnSelect:
ClearCollect(SearchRoom, ThisItem); Collect(PreviousSearchRoom, SearchRoom);Navigate(DetailScreenSearch, Fade)
This method uses 2 collections: SearchRoom and PreviousSearchRoom. I haven't really used collections before, but I was able to dissect the 'Employee Org' powerapp template to get an understanding of what was required.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
256 | |
126 | |
85 | |
85 | |
68 |