Search code examples
google-app-maker

Trying To Filter Only Rows That Meet Two Criteria


I promise I have read through the Query information page, but obviously I am missing/misunderstanding something.

I have a Table that has the statuses for multiple departments (the fields are Strings). When a user loads that table I want App Maker to hide jobs that have been finished.

The way we categorize a job as finishes is when:

The Inventory Status = Complete and when the The Delivery Status = Delivered.

Both these conditions need to be met.

Example:

Inventory (Complete) + Delivery (Delivered) = hide

Inventory (In Progress) + Delivery (Delivered) = don't hide

Inventory (Complete) + Delivery (Scheduled) = don't hide

I tried the following, however it hides all the example listed above, not just the first one.

var datasource = app.datasources.SystemOrders;
var inventory = ['Complete'];
var delivery = ['Delivered'];
    datasource.query.filters.InventoryStatus._notIn = inventory;
    datasource.query.filters.DeliveryStatus._notIn = delivery;
    datasource.load();

I have also tried this:

var datasource = app.datasources.SystemOrders;
    datasource.query.filters.InventoryStatus._notIn = 'Complete';
    datasource.query.filters.DeliveryStatus._notIn = 'Delivered';
    datasource.load();

But I get this error:

Type mismatch: Cannot set type String for property _notIn. Type List is expected. at SystemOrders.ToolBar.Button2.onClick:2:46

Any help would be greatly appreciated.


Solution

  • Filters are using AND operator. Please consider switching the Datasource Query Builder and applying the following query:

    "InventoryStatus != :CompleteStatus OR DeliveryStatus != :DeliveredStatus"

    Set CompleteStatus variable to Complete Set DeliveredStatus variable to Delivered

    Explanation: Filter you want to apply is "NOT(InventoryStatus = Complete AND DeliveryStatus = Delivered)" which is equivalent to "InventoryStatus != Complete OR DeliveryStatus != Delivered".