Definition: Call this from an ItemHit handler for a code field to invoke an autocomplete dropdown. TableName may be one of "account", "ledger", "product", "job", "department", "name", "list".
Example: Autocompleting against values from a database table.
on ItemHit:F_TRANS:E_USER1(w, f) AutoFillField(w, f, "department") end
Programmed autocomplete for a validation list:
As of v8.1.8 the third parameter may be a mnemonic indicating a validation list. I.e. a string of the form "List:listname" where listname is the name of a validation list. This allows list validations to be applied programmatically for all users rather than manually setting up autocompletion for fields for each user.
on ItemHit:F_TRANS:E_USER1(w, f) AutoFillField(w, f, "List:branches") // where branches is a defined validation list end
Supplying full calculated autocomplete data:
Also as of v8.1.8 the third parameter may be an associative array of codes and descriptions, or a specially formatted tab-delimited table with entries in the form: space code tab space description newline. In these cases the supplied validation data is used to match the input for autocompletion.
property mytext // autocomplete only AUD control accounts on Load let mytext = Find("account.` `+code+`\t `+description", "currency = `AUD`", 9999, "\n") end on ItemHit:F_TRANS:E_USER1(w, f) AutoFillField(w, f, mytext) end
If building autocomplete data this way, you should do it once per session and cache it in a property. Do not build it every time you call AutoFillField as that will not scale.
Availability: available within MWScript handlers.