Lookup filed: Advanced query

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
jgjuran
Posts: 3
Joined: 2020-04-17 21:43

Lookup filed: Advanced query

Post by jgjuran » 2020-04-18 19:51

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

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Lookup filed: Advanced query

Post by pbottcher » 2020-04-18 22:07

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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

jgjuran
Posts: 3
Joined: 2020-04-17 21:43

Re: Lookup filed: Advanced query

Post by jgjuran » 2020-04-19 20:27

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.

Post Reply