Pragmatic Works Nerd News

How YOU can Fix Search in Canvas Apps! πŸ”

Written by Matt Peterson | Nov 15, 2024

In this video, Matthew Peterson provides a solution for fixing issues with the search function in Canvas Power Apps. Recently, some users have experienced problems where the search feature that previously worked fine suddenly fails to return results, especially with certain data sources. Matthew walks through a practical workaround to resolve this issue by using a global variable and a simple trick to simulate user interaction with the search field.

 

Understanding the Search Bug

Search functionality in Power Apps typically works by allowing users to type text into an input field, which filters data in a gallery based on the entered text. However, there have been recent reports where the search function appears to be "stuck," and no results are returned, even when the input field is used correctly. This issue is primarily seen with delegable data sources like SQL, where Power Apps relies on the data source to handle the search operation.

Step-by-Step Workaround

To work around this bug, Matthew introduces a simple solution using a global variable. The idea is to "trick" the input control into behaving as if a user had typed something and then erased it, causing the gallery to reload correctly. Here's how it works:

  1. Create a text input field for the user to type their search query and remove any default text from the input’s Default property.
  2. Set up a global variable in the app’s OnStart property to automatically simulate the input of a character followed by its removal.
  3. In the OnStart property, use Set(VAR_Search, " ") followed by Set(VAR_Search, "") to set the search input to a space and then clear it.
  4. Assign the variable to the Default property of the search input control.
  5. Run the OnStart function to trigger the simulated input and force the search results to display properly.

Addressing the Bug in Delegable Data Sources

Matthew explains that this issue mainly affects data sources where search is delegable, such as SQL Server, meaning the data source itself performs the search. In non-delegable data sources, like SharePoint, Power Apps handles the search, and the issue may not appear. The workaround ensures that search functionality is restored, regardless of the data source.

Conclusion

If you've encountered problems with search in your Canvas apps, this video provides a quick and effective workaround to ensure your galleries display search results correctly. By using a global variable and simulating input, users can bypass the issue until a permanent fix is available. 

Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power Apps and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up to date on the latest tips and tricks.