Search code examples
google-app-maker

Conditional Search Results


I'm creating a 'Kiosk' where users can sign-in and out. I'm stuck on the sign-out component.

I'd like to have a table that only returns visitors that have not signed out after the end-user searches.

My search box has the following properties:

Value:

@datasource.query.filters.fullname._startsWith

On value change:

if (widget.value === null || (widget.value).length === 0){
    widget.datasource.unload();
} else {
    widget.datasource.load();
}

I'm new to this & JS as a whole. How can I filter the search to only contain users that have not signed out?


Solution

  • As suggested in the comments you need to add widget.datasource.query.filters.signedout._equals = false; line before you load your data source. However you should make one more change while unloading.

    Here's the full code.

    if (widget.value === null || (widget.value).length === 0){
        widget.datasource.unload();
        widget.datasource.load();
    } else {
        widget.datasource.unload();
        widget.datasource.query.filters.signedout._equals = false;
        widget.datasource.load();
    }
    

    Here unload() will unload previous data and load() will reload it. Now while reloading you can pass multiple filters so it reloads only filtered records.