WHERE ID NOT IN Advanced Lookup Issue

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
khouse
Posts: 11
Joined: 2019-05-12 14:34

WHERE ID NOT IN Advanced Lookup Issue

Post by khouse » 2020-01-24 23:25

Hello all - I'm trying to filter my results for a lookup field via the advanced option to not include user records from another table.

I was going to simply uncheck the "Show all records of the parent table" option and modify the query with a nested query, but I'm not sure how given I can't include the user name.

Basically I want to see the records from that user, but not if that record already exists in the alternates table. Any ideas? Thanks in advance.

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

Re: WHERE ID NOT IN Advanced Lookup Issue

Post by pbottcher » 2020-01-25 08:12

Hi,

I don't think you can do this via the customization of the advance query option. Instead you need to put your query together in the hooks/FILENAME.php file within the INIT function.

Set the

$options->QueryWhere = 'WHERE ....';

to your needs.

Here you can grap the actual user from the $memberInfo array.
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.

khouse
Posts: 11
Joined: 2019-05-12 14:34

Re: WHERE ID NOT IN Advanced Lookup Issue

Post by khouse » 2020-02-06 00:24

Thank you but it appears that they QueryWhere is filtering the main table display, not the dropdown list which is controlled by the Advanced lookup options. Maybe they will introduce a LookupQueryWhere option in the future. Is there any other way to solve this?

khouse
Posts: 11
Joined: 2019-05-12 14:34

Re: WHERE ID NOT IN Advanced Lookup Issue

Post by khouse » 2020-02-21 23:22

I solved this by creating an insert hook that checks for duplicates in the parent table before it allows the insert. So you can still select and attempt to add a duplicate, but it will stop you.

Post Reply