Page 1 of 1

How? Custom SQL for lookup but using value from record as WHERE

Posted: 2021-01-07 12:12
by onoehring
Hi,

I have this setup:
Table tbl_boxes: Holds boxes
Table tbl_customers: hols customer information
Table tbl_customers_boxes: holds current (!) relation between customers and boxes (m:n). The relation will change.
Table tbl_jobs: holds jobs that need to be done with tbl_boxes.

In tbl_jobs the customer needs to be saved forever (history). For this reason I would pull him from tbl_customers (where he always exists) and not from tbl_customers_boxes (as the customer can vanish from tbl_customers_boxes).

Problem: I can not do this in AG with the lookup afaik.

I can not use a "dependent lookup" with tbl_customers (with tbl_customers_boxes it would work), but I need to show only customers for a job that actually have currently an entry in the current tbl_customers_boxes table.

So I am wondering, if I can use a field from the current record (ID_boxes) in my custom lookup query - and if yes, - how do I do this?
If no, it would be a great feature to be able to use a field from the current record in a custom lookup query.

Olaf

Re: How? Custom SQL for lookup but using value from record as WHERE

Posted: 2021-01-11 12:14
by onoehring
Hi,

just wondering if anyone can tell me, if there is a way or, that there is currently no way to use table field-values in custom SQL queries.

Olaf

Re: How? Custom SQL for lookup but using value from record as WHERE

Posted: 2021-01-11 16:54
by pbottcher
Hi Olaf,

not sure I got everything you need, but in the init function you can modify the query to your needs. Maybe that helps

Re: How? Custom SQL for lookup but using value from record as WHERE

Posted: 2021-01-11 16:57
by onoehring
Hi pbötcher,

yes, I know that, but for my setting - I may be missing something - I need to change the lookup-source (according to some value in my current displayed record) but keep my table-source.


Olaf

Re: How? Custom SQL for lookup but using value from record as WHERE

Posted: 2021-01-11 17:00
by pbottcher
Maybe you can make a sample to see if that would work

Re: How? Custom SQL for lookup but using value from record as WHERE

Posted: 2021-01-11 17:25
by onoehring
Hi pbötcher,

what do you mean? Am I able to change the source of a lookup in the _init function?

Olaf

Re: How? Custom SQL for lookup but using value from record as WHERE

Posted: 2021-01-11 19:58
by pbottcher
Hi Olaf,

no you cannot.

Re: How? Custom SQL for lookup but using value from record as WHERE

Posted: 2021-01-13 07:11
by onoehring
Hi pbötcher,

thank you. I posted a feature request ( viewtopic.php?f=6&t=4119 ).

Olaf