Page 1 of 1

Lookup filed: Advanced query

Posted: 2020-04-18 19:51
by jgjuran
I am using APPGINI 5.82 and applying a default filter to ALL tables using the tablename_init hook file. I incorporated a session variable (defined after a successful login) in the filter and it works just fine (shown):
addFilter(1,'and',2,'equal-to',$_SESSION["COMPANY"]);

I then tried a similar approach for the advanced query box in a Department table lookup field, modifying the default query by adding the condition:
WHERE `department`.`Company` = $_SESSION ["COMPANY"]

The query fails.

(FYI, the query will run properly if condition is modified to WHERE `department`.`Company` = 999 )

Is there a solution to including a variable in a lookup field query?
Thanks
joseph

Re: Lookup filed: Advanced query

Posted: 2020-04-18 22:07
by pbottcher
Hi,

you may have a look at the

$options->QueryWhere

in the init function of the hooks/TABLENAME.php file.

Here you can apply your changes. In the AppGini advanced lookup I think this is not possible.

Re: Lookup filed: Advanced query

Posted: 2020-04-19 20:27
by jgjuran
Thanks for taking the time to respond.

FYI, below is the response I received from tech support at APPGINI. A solution is in the work so will just have to wait!

The addFilter command works when using $_SESSION because it works inside PHP context rather than SQL. But we plan to add support for special tags to use in the advanced SQL tab .. for example %username%, %custom1% .. etc.