Search code examples
google-app-maker

In Google App maker, How are Query Script parameters added?


I am trying to figure how to use a DateBox widget to filter the datasource using a query-script. But I don't know how to add parameter variables to the script.

When using query-builder, there is a special button to add query parameters. However, there is no mention in the docs on where to add query parameters when writing a query-script.

docs -> https://developers.google.com/appmaker/models/datasources#query_script


Solution

  • It looks like since you asked the question docs were updated. Here is the latest code snippet from the docs:

    // Modify passed query to additionally filter by minimum age
    // if client asks us to do so.
    if (query.parameters.RestrictAge) {
      query.filters.Age._greaterThan = 20;
    }
    
    var employees = query.run();