rgmrtn
rgmrtn

Reputation: 155

How do I pass a parameter to a query script from a dropdown widget?

I am trying to pass a string value containing a "category" to a query script through a custom parameter:

Query Script

Then filter the datasource by that parameter, but when I reload the datasource on ValueEdit of the dropdown, it does not filter the table records. In addition, I have the script output a console message supposedly containing the "categoryParameter" but it shows up undefined.

Any assistance would be greatly appreciated.

Console Output

Upvotes: 1

Views: 886

Answers (2)

Alexis
Alexis

Reputation: 11

For everyone who might need it, I was stuck in this particular case. The query is transmitted like a parameter in a function.

Do not initialize the variable "query" or you will overwrite it.
Use directly :

var parameter = query.parameters.your_parameter

and not

var query = app.model.your_model.newQuery();
var parameter = query.parameters.your_parameter;

Upvotes: 1

Pavel Shkleinik
Pavel Shkleinik

Reputation: 6347

You need to bind your dropdown's value to the query parameter. Binding similar to this should work:

@datasources.MyDatasource.query.parameters.categoryParameter

or in case the dropdown is already bound to the MyDatasource smth like this:

@datasource.query.parameters.categoryParameter

Upvotes: 1

Related Questions