Forums

CF6 - Dropdown - autocomplete - strange WHERE clause behaviour in DBRead

gix.vax 01 May, 2018
hi

a dropdown (idlivello2) in a form have a strange behaviour

i follow the example with json method

- no data source in dropdown
- autocomplete call the event livello2

the EVENT livello2 have
1) a read_data15 that have two module connected (primary is livello2 and configurazioni is the secondary)
the WHERE is this
livello2.livello2/LIKE:%{data:idlivello2}%
configurazioni.idimbarcazione:{data:idimbarcazione}
2) a custom code
{var/jsonen:read_data15}

idimbarcazione is an array data passed correctly to this form
infact i test using THE SAME read_data at the top of the form and it works
but i need autocomplete after pushing a character, then i need it in the event livello2.

For test: if i put a (correct) number
e.g. configurazioni.idimbarcazione=24
it works

i have a field that contain idimbarcazione and is regularly populated

it seems that idimbarcazione become empty if i call it in the event

someone can help me?
healyhatman 02 May, 2018
You need to either pass idimbarcazione as a URL parameter when you call the event, or reload it from the database at the start of the event.
gix.vax 02 May, 2018
thank you for the answer,

but in CFv6 the event is called directly from the autocomplete event parameter of the dropdown filed

where i have to put the string
idimbarcazione={data:idimbarcazione}
???

or i need to save session and use a differnt syntax in the WHERE clause?
something like
idimbarcazione={session:idimbarcazione}
???

and why idlivello2 is used without passing it and idimbarcazione not?
cause is itself and is passed automatically by the autocomplete?

thenk you
healyhatman 02 May, 2018
You can save to session on load, or just get it from the database again in the event.

idlivello2 is passed because it's the calling field.
gix.vax 02 May, 2018
thank you again
idimbarcazione come from data from another form so i think i have to save to session

for information
is there a way to pass to the EVENT the idimbarcazione through DATA array ?
gix.vax 03 May, 2018
Answer
i post solution with saving session if could be useful for somene else

in SETUP
before event is loaded (in my case is after reading data at the top of the form)
explanation:
take from SESSION a save to session and put in your form
- call it sessiondata or wathever you want
- data provide {data:}

now you have your array saved that survive through events and is in sessiondata
you can call the entire session variable in this way
{session:sessiondata}
or a specific value in this way
{session:sessiondata.idimbarcazione}

:-)
This topic is locked and no more replies can be posted.