I wrote a session with extended search on BP's. Depending on where the session is called from, the relevant type of BP will be sales-to, inv-to, pay-by etc. The users enters some search arguments on the top part of the form, and the search results are displayes on the lower part (multi-occ).
The main table stays tccom100, but depending on the type of bp, I add a reference control in my query.extend.where to the relevant table. Below you will find a piece of my code.
I encounter 2 dificulties using query extension:
a) I have an enum field as search field; status (tccom100.prst). When I include the check on status in my query.extend.where, it goes wrong. No records are selected, no matter what the user fills on the screen.
Here a piece of the code:
Code:
function search.sls.to()
{
query.extend.where("tccom100.nama inrange :nama and :nama.t" &
" and tccom100.seak inrange :seak and :seak.t" &
" and (prst = EMPTY or tccom100.prst = :prst)" &
" and tccom100.fovn inrange :fovn and :fovn.t" &
" and tccom100.cadr refers to tccom130" &
" and exists (select tccom110._index1" &
" from tccom110" &
" where tccom110._index1 = {:tccom100.bpid})" &
" and tccom130.namc inrange :namc and :namc.t" &
" and tccom130.hono inrange :hono and :hono.t" &
" and tccom130.name inrange :name and :name.t" &
" and tccom130.pstc inrange :pstc and :pstc.t" &
" and tccom130.ccty inrange :ccty and :ccty.t")
}
I also tried to replace that line with
" and tccom100.prst = :prst" &
but that also doesn't return results.
The form-field prst has the same domain as tccom100.prst (tccom.prst). When I debug, I see that the field.prst.when.field.changes section is ignored, even when the field is changed. The value of prst seems to stay on EMPTY... Is there any limitation or special setting required to use enum fields on the form.
The second issue is that I actually want the check on address code (cadr) to be on tccom110, and not on tccom100. But when I do that like below, I get syntax errors on runtime.
Code:
function search.sls.to()
{
query.extend.where("tccom100.nama inrange :nama and :nama.t" &
" and tccom100.seak inrange :seak and :seak.t" &
" and (prst = EMPTY or tccom100.prst = :prst)" &
" and tccom100.fovn inrange :fovn and :fovn.t" &
" and exists (select tccom110._index1" &
" from tccom110" &
" where tccom110._index1 = {:tccom100.bpid})" &
" and tccom110.cadr refers to tccom130" &
" and tccom130.namc inrange :namc and :namc.t" &
" and tccom130.hono inrange :hono and :hono.t" &
" and tccom130.name inrange :name and :name.t" &
" and tccom130.pstc inrange :pstc and :pstc.t" &
" and tccom130.ccty inrange :ccty and :ccty.t")
}
Thanks in advance,
En