The lookups setting defines a map of field names and their SQL WHERE clauses to invoke the display of data from another table. It is an optional property.
Note: Before proceeding, get acquainted with the Settings Levels section of LyciaLowCode Settings page (the concept of scopes is essential for configuring multiple interactions and the multitable support).
The definitions like LET <setting_variable>.<setting_name> = <value> refer to the InteractForm_Settings level, while LET <setting_variable>.views["<db_table_name>"].<setting_name> = <value> refers to the View level.
This setting can be defined for:
InteractForm_Settings level: No
View level: Yes
To create a definition for a lookup, specify the following parameters:
<InteractForm_Settings>.views["<db_table_name>"].lookups["<form_field_to_populate>"] = "<db_table_2_name>.<db_table_2_FK_field> = <db_table_1_name>.<db_table_1_PK_related_data>"
Here, <form_field_to_populate> is a name of the form field to display data to, <db_table_2_name>.<db_table_2_FK_field> is the data related to the Primary Key in the database table.
Thus, the lookup field in the form displays the relationship of form FK field to other table's PK.
To define the lookup in .fm2 form file, add the forementioned values as values for the lookups key:
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://namespaces.querix.com/2015/fglForms"
interactSettings='
[
{
"id": "lookup",
"paged_mode": 1,
"views":
{
"test05": {
"screen_record": "scr_with_lookup",
"lookups":
{
"country.country_name": "address.country_code_fk = country.country_code_pk"
}
}
}
}
]
'>