Implement real-time search in Gallery of CDS records in a Canvas Power App | Power Platform

One of the most common asks is to be able to search CDS records in a Gallery control in real-time using a Text-box.

Search Box & Gallery connected to CDS

Let’s design a simple gallery that is populated with CDS records from Account entity.

  1. Take a Text Input control (Textbox) and make it look like a Search Box.

    In order to have the Search watermark, write the text to appear as water-mark, enter it in Hint text property of the Text input


  2. Take a Gallery control and select Data Source as Accounts from CDS.


    The way the above shown Gallery control is populated is by selecting a CDS Data Source which is as below –

Filter records

Finally, there’s a 1-line formula that will do the trick for you

  1. In the Items property of the CDS Gallery, I have to filter the records based on the Text of the Text Input on my form.


    Marked by green arrow Filter() function is the one which handles filtering of the data set based on the parameters demanded by the method. Here’s Microsoft Docs on the same – https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-filter-lookup

    Underlined by red Accounts is the CDS data source which I want to filter on.

    StartsWith() is a method which is used to compare the start of the string in question. In this case, the text I enter in the SearchField textbox.

    1. ‘Account Name’ is the field in the Accounts dataset to be considered on which the search parameter is dependent.
    2. Underlined by purple SearchField.Text in which SearchField is the textbox which is used to query the Name of the Account and .Text is Text value of the string which will be considered.

    So at all times, whenever there’s a change in the Textbox value, the Items of the Gallery control are supposed to be updated with the filtered records.

Working

Now, when you use the App, here’s what it will behave like. As you type, the records will filter with a certain delay (depending on how large your dataset is)

Hope this was useful!!

Here are some more Canvas Power Apps posts you might want to check –

  1. https://d365demystified.com/2020/08/31/log-canvas-power-app-telemetry-data-in-azure-application-insights-power-apps/
  2. https://d365demystified.com/2020/08/25/call-http-request-from-a-canvas-power-app-using-flow-and-get-back-response-power-automate/
  3. https://d365demystified.com/2020/08/16/send-a-power-app-push-notification-using-flow-to-open-a-record-in-canvas-app-power-automate/
  4. https://d365demystified.com/2020/08/07/recover-deleted-d365-powerapp-environment-using-powershell/
  5. https://d365demystified.com/2020/08/07/recover-deleted-d365-powerapp-environment-using-powershell/

Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.