0
votes

I created a Datasource named Horas whith a Query Server Script, and I make a Custom Parameters named Usuario.

I bind in a page with datoasource Horas as

textField.value <-> datasource.query.parameters.Usuario

And I get the error:

Error: Parameter 'Usuario' is used in 'where' clause but not defined in property 'parameters'. at datasources.Horas

Horas is a Query Server Script datasource

  var query = app.models.Registros.newQuery();
  query.where = 'Usuario =? :Usuario';
  var allRegistros = query.run();

I expected to get a table with data filtered by Usuario, How to get ride of the error?

1

1 Answers

0
votes

When using query script, instead of query builder, in conjunction with a where clause then your query parameter is in fact separate from your parameter used in the where clause. Your possible solutions are to switch your datasource to query builder or to adjust your code in your Query Server Script as follows (also note, there is no need to declare your query for the datasource in the query script, you simply just use query and you when using query script you do have to use return):

query.where = 'Usuario =? :Usuario';
query.parameters.Usuario = query.parameters.Usuario;
return query.run();

If that doesn't work let me know. And yes, you do in fact have to declare the parameter Usuario in the where clause and then set it equal to the parameter you are using the actual query parameters. It is kind of weird that way.