Check scope when binding to queries in Preparation

By Justin James on 19 Aug 2013
Scenario:

Query is in Preparation, but in a branch of logic that is not always going to be run.

In the Preparation, actions outside the guaranteed scope of the query cannot use it.

But on the screen, they can.

Result: binding data to queries that will not always have results, and errors.

Suggestion: do not allow access to query results on the screen unless the query is in a logic path that will always be run.
Hello Justin,

This would mean not every query can be 'reached' used directly in the screen/other actions, which would mean you need local variables to assign it to so you can use it in the screen.

From my side it more annoying I can't use the results from actions directly in the screen which are set in my preparation (but behind an if statement or something like that).

Kind regards,
Evert
Justin James3 Sep 2013
Evert -

That is true, but your use case violates the spirit of OutSystems scope checking. :D

Which is exactly why I brought it up, I *accidentally* did what you do on purpose, and it caused errors.

J.Ja
Fernando Sousa24 Oct 2013
Hello,

It's a bit scary that queries are always in scope in action flows. Worst than showing widget bound to a query that has not been executed is using the "results" of that query prior to its execution in action flows:


I think situations like these should be validated. However, that could have a serious side-effect as Evert mentioned: not being able to use query results directly in screen widgets (as it happens today with action results), not being able to use refresh query widgets in other screen actions.
Kilian Hekhuis25 Oct 2013
Queries seem to act like local variables as far as scope is concerned, which makes some sense as the query object is a local variable, for all intents and purposes. Especially since the introduction of the Refresh Query, it wouldn't make sense to block access to it, but also directly displaying the result in a table record would be impossible.