When OnScriptInit in grid app is executed?

Hello,
I dont understand if OnScriptInit in grid app is executed before or after the execution of the select query.

Documentation says:
Grid - onInit
Second event to be executed, before the execution of the main select, it is triggered whenever the application is loaded. For example, after using the advanced filter.
In it, all application variables and libraries are available for use.

But to me it seems it executed AFTER and NOT BEFORE the main select

For sure it is executed before the main SQL select.

I’m using it frequently for changing the WHERE part of the select by
sc_select_where(add) = ...

Best

Gunter Eibl

Hy Gunter,
well from my test it depends on the initial module loaded.
If the initial module is the grid I agree with you. OnScriptInit is executed BEFORE the main select.
But if the initial module is not the grid but the chart (see screenshot attached to understand what I mean) then the OnScriptInit is execute AFTER the sql query that build the chart and therefore any variable assigned inside OnScriptInit will not be passed to the main select.

Hi maxi,
ok, didn’t know this.

Have you ever tried to assemble the WHERE in onApplicationInit ?

You will not be ablte to use sc_select_where(add) there, but you could put it into a global variable like
[my_where] = " WHERE x=y "
and also place that [my_where] into the SQL statement of the Grid.

Remember to set the my_where in Application>Global variable to optional and out :wink:

Hope that workaround can help you…

Best
Gunter Eibl