Basics of Lycia LowCode Configuration
The ‘InteractForm_Settings’ Record
Defining Lycia LowCode Settings
Defining Settings in .4gl File
Lycia LowCode has two types of records to manage settings for interactions:
All the settings available are taken from those records. This data has to be set before starting the interaction and cannot be changed during execution.
To configure Lycia LowCode, you need to do the following:
Step 1. Link the LowCode library in your program and call one of the functions to invoke the LowCode as specified in the following page: Starting Your Work With Lycia LowCode.
Step 2. Create a function with LyciaLowCode settings, create a record for your Lycia LowCode settings, and assign the values like in the example below (the explanation for every setting will follow in the further sections of this page):
FUNCTION db_cms_virtual_field_rec()
DEFINE rec_settings InteractForm_Settings
LET settings.form_file = "../misc/misc_virtual_field_rec"
LET rec_settings.id = "virtual_field"
LET rec_settings.log_file = "../log/db_cms_virtual_field.log" #enable log file
LET rec_settings.actions[""]["ON ACTION Show Data"] = FUNCTION math_on_action_show_data
LET rec_settings.actions[""]["AFTER ROW"] = FUNCTION math_on_action_show_data
LET rec_settings.actions["UPDATE"]["AFTER INPUT"] = FUNCTION math_after_input
LET rec_settings.actions["INSERT"]["AFTER INPUT"] = FUNCTION math_after_input
LET rec_settings.views["test03"].navigation_status="nav_page_of"
TYPE InteractForm_Settings RECORD form_file STRING, # The form file that should be opened. id STRING, # Optional, a form file can contain multiple InteractForm settings, and each can be selected by 'id'. log_file STRING, # The path to log file. It's an optional property. translations HASHMAP OF STRING, # Map of internal message translations. views HASHMAP OF View, # The mapping of database table name and its matching settings in the specific interaction. actions HASHMAP OF HASHMAP, # Custom actions "SubInteraction - Action - Function", which will be added to the subdialog of defined table view and executed before LLC built-in event executing. actions_on_done HASHMAP OF HASHMAP, # Custom actions "SubInteraction - Action - Function", which will be added to the subdialog of defined table view and executed after LLC built-in event executing. view_attributes HASHMAP OF HASHMAP, # Custom attributes "SubInteraction - Attribute - Value", which will be applied to the Dialog. paged_mode INT, # If positive, then the buffer should be used (in this case, it will take less time for starting interaction). The default is "-1". input_mode INT, # If negative or 0, then the DISPLAY ARRAY should be used, otherwise (positive) the INPUT ARRAY is used. The default is "-1". pessimistic_locking INT, # Pessimistic row locking is disabled by default (disabled option locks table only for the time of the actual db update). The default is "-1". confirm_accept INT, # If positive, then it shows a message box for yes/no/cancel when data has been changed AND the user presses ACCEPT. The default is "-1". confirm_cancel INT, # If positive, then it shows a message box for yes/no/cancel when data has been changed AND the user presses CANCEL. The default is "1". END RECORD
The settings from the View record are used to customize a certain interaction with a certain database table. Each program has at least one View (interaction with a table), but with two or more Views, you can define several collections of settings to configure different interactions. You can assign a name for each collection (an id).
If the setting has not been defined for the View, Lycia LowCode will use the definition from the InteractForm_Settings level.
To use multiple database tables for your program, configure multiple Views. The settings of the View are the following:
TYPE View RECORD screen_record STRING, # The screen record name in the form that should be used. It's a mandatory property. actions HASHMAP OF HASHMAP, # Custom actions "SubInteraction - Action - Function", which will be added to the subdialog of defined table view and executed before LLC built-in event executing. actions_on_done HASHMAP OF HASHMAP, # Custom actions "SubInteraction - Action - Function", which will be added to the subdialog of defined table view and executed after LLC built-in event executing. view_attributes HASHMAP OF HASHMAP, # Custom attributes "SubInteraction - Attribute - Value", which will be applied to the subdialog of defined table view. not_update_fields DYNAMIC ARRAY OF STRING, # The list of field which should not be activated on the Edit action. paged_mode INT # If positive, then buffer will be used (in this case it will take less time for starting interaction). input_mode INT # If negative or 0, then DISPLAY ARRAY will be used; if any positive value, INPUT ARRAY will be used. pessimistic_locking INT # Pessimistic row locking is disabled by default (optimistic does not lock table during input, but only for the time of the actual db update). sql_where_search STRING # The WHERE clause of the main query that can be overwritten as soon the user applies a Search (Construct). sql_where STRING # The WHERE clause of the main query that can NOT be overwritten by user. sql_order_by STRING # The ORDER BY clause for the main query. sql_top INT # The option to limit the base cursor row using the SQL SELECT TOP clause. confirm_accept INT # If positive then it shows a message box for yes/no/cancel when data has been changed AND the user presses ACCEPT. The default is negative (-1). confirm_cancel INT # If positive then it shows a message box for yes/no/cancel when data has been changed AND the user presses CANCEL. The default is positive (1). comboboxes HASHMAP OF Combobox # Map of combobox field names and its sql where clause and dependencies. lookups HASHMAP OF STRING # Map of lookup field names and its 'match' string that will be used in SQL WHERE clause. zooms HASHMAP OF Zoom # Map of functionfield names and definitions of form for selecting value. navigation_status STRING # Target location for the DISPLAY of navigation status (which can be a label or a textField). END RECORD
There are two mandatory settings:
If you plan to have multiple Views in your program, you can specify settings for each of such Views (interactions). Those will be the collections of settings, and you can assign a name to each of such collections. To do that, use the id setting. This way, you can reuse the same form for different purposes.
Two Ways of Specifying LLC Settings
You can define Lycia LowCode settings in the following ways:
LET rec_settings.paged_mode = 1
LET rec_settings.views["<table_name>"].confirm_accept = 1
You can also disable any LyciaLowCode setting in a certain View while having it enabled in another View.
Step 1. Link the Lycia LowCode library lib_llc_interact_form/llc_interact_form.4gl in your project:
Step 2. Call one of the following functions:
# 3 ways of invoking LowCode:
# PUBLIC FUNCTION InteractFormFile(formFile STRING)
# PUBLIC FUNCTION InteractFormFileWithSettings(form_file STRING, setting_id STRING)
# PUBLIC FUNCTION InteractForm(rec_settings InteractForm_Settings)
Step 3. Create a function with Lycia LowCode settings and assign the values, like in the example below:
FUNCTION db_cms_virtual_field_rec()
DEFINE rec_settings InteractForm_Settings
LET md_log_console = NULL #clear console screen variable
LET settings.form_file = "../misc/misc_virtual_field_rec"
LET rec_settings.id = "virtual_field"
LET rec_settings.log_file = "../log/db_cms_virtual_field.log" #enable log file
LET rec_settings.actions[""]["ON ACTION Show Data"] = FUNCTION math_on_action_show_data
LET rec_settings.actions[""]["AFTER ROW"] = FUNCTION math_on_action_show_data
LET rec_settings.actions["UPDATE"]["AFTER INPUT"] = FUNCTION math_after_input
LET rec_settings.actions["INSERT"]["AFTER INPUT"] = FUNCTION math_after_input
LET rec_settings.views["test03"].navigation_status="nav_page_of"
Note: For defining settings to control all the interactions of a program, use the following format:
LET <settings_variable>.<setting_name> = <setting_value>
For defining settings for the interaction with the specific database table, use the following format:
LET <settings_variable>.views["<db_table_name>"].<setting_name> = <setting_value>
Step 1. Although the settings themselves can be set in a form file, you need to link Lycia LowCode library in your .4gl file before defining specific settings:
Step 2. In .fm2 form file, create a JSON record that will specify the settings of a main level by the following structure:
<form xmlns="http://namespaces.querix.com/2015/fglForms"
interactSettings='
[
{
"<setting_1_name>":<setting_1_value>,
"<setting_2_name>":<setting_2_value>,
...
"<setting_n_name>":<setting_n_value>
}
]'>
If your form needs several Views, assign an id for each of such Views and put the settings for a specific View into the array as a value for the views key.
For example, the program demo_contact_activity is supposed to have three Views. Hence, the .fm2 form file for this program will have three arrays of View settings inside a main JSON array:
<form xmlns="http://namespaces.querix.com/2015/fglForms"
interactSettings='
[
{
"id": "Contact - Activity",
"views": {
"contact" : {
"screen_record": "scr_contact"
},
"activity" : {
"sql_where": "activity.contact_id = contact.cont_id",
"screen_record": "scr_activity"
}
}
},
{
"id": "Contact Only",
"views": {
"contact" : {
"screen_record": "scr_contact"
}
}
},
{
"id": "Activity Only",
"views": {
"activity" : {
"screen_record": "scr_activity"
}
}
}
]'>
Lycia LowCode uses the dynamic DIALOG clause, which by default works UNBUFFERED and WITHOUT DEFAULTS.
You can override that behaviour. To do that, use the view_attributes setting:
DEFINE l_settings InteractForm_Settings # defining a variable for LowCode interaction
LET l_settings.view_attributes[""]["UNBUFFERED"] = FALSE
LET l_settings.view_attributes[""]["WITHOUT DEFAULTS"] = FALSE
Related Articles