Search code examples
google-app-maker

Filters in AppMaker


I have created one datasource which contains only the rows that fulfil one condition. I want to create some filters in this table... but is not working.

This is the datasource: enter image description here

For example, I have a text area which filters by the field "Title". Only should appears the row 5 , but the numer 6 it's still here...

enter image description here

This is the event handler code:

enter image description here

Important: in the beginning, I used this filters and they worked properly. They stopped working when i created the filter in the datasource (The one of the first image)


Solution

  • The filter that you are setting via the binding is getting lost when you perform your query script. Essentially, you are creating a query via the binding, then your script is creating a new query that doesn't have the filters you set previously.

    Server Script - queryRecords(query: Query)
    

    You'll notice that your query script has access to a parameter query that you can use instead of calling newQuery(). This will have the filter you set via your binding. Additionally, query.run() returns a list of records, so there's no need to iterate over them. Here is all the code you need in your query script:

    query.filters.Status._in = ["Published"];
    return query.run();