'actions' and 'actions_on_done': Function Calls on Actions and Events

'actions’ Setting Overview

Record Edit Mode on DOUBLECLICK in DISPLAY ARRAY (List View)

Built-In and Custom Actions

Disabling the Built-In Actions

'actions_on_done': Arranging Custom Actions Execution After the Built-In Actions

Using the ON CHANGE Clause With Lycia LowCode

The Function Signature

SQL Operations In Lycia LowCode

'actions' Setting Overview

Actions are defined for a particular view (global view or one particular table view) and an action / event scope by using one of the scope definitions shown below:

Note: If the action / event scope is defined as an empty string, it will default to the DIALOG scope.
Note: On INSERT (INPUT for a new record), you will have a built-in action with the identifier "BEFORE FIELD <FieldName>".

There are:

Note: Before proceeding, get acquainted with the Settings Levels section of LyciaLowCode Settings page (the concept of levels 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: Yes

View level: Yes

Defining an action (custom) for any / all views:

LET <InteractForm_Settings>.actions["<ActionScope>"]["ON ACTION <Action / Event Identifier>"] = <call the function without any arguments>

Defining an action mapped only for a particular view (table name):

LET <InteractForm_Settings>.views("<tableName>").actions["<ActionScope>"]["ON ACTION <Action / Event Identifier>"] = <call the function without any arguments>

Example 1:

LET settings.actions["ANY"]["AFTER FIELD country"] = FUNCTION myfunc

Example 2:

LET settings.actions[""]["BEFORE DISPLAY"] = FUNCTION custom_before_display

LET settings.actions[""]["ON ACTION Accept"] = FUNCTION table_view # Adding custom action

Example 3:

LET p_rec_settings.views["contact"].actions[""]["ON ACTION ContactOnly"] = FUNCTION ContactOnlyFunc

Note: Alternatively, you can specify this setting in JSON array in .fm2 form file by the following example: Defining Settings in .fm2 Form File.

 

Return to top

 

Record Edit Mode on DOUBLECLICK in DISPLAY ARRAY (List View)

When the data is displayed in the form of alist (DISPLAY ARRAY, List View), double-clicking on any row will invoke another LyciaLowCode process that will offer the user to edit the corresponding row in a Detailed Record View:

FUNCTION settings_list()

DEFINE l_settings InteractForm_Settings

 

LET l_settings.form_file="../llc_settings/llc_settings_list"

LET l_settings.actions[""]["ON ACTION DOUBLECLICK"] = FUNCTION settings_rec_input

LET l_settings.actions[""]["BEFORE ROW"] = FUNCTION actions_set_m_pk

CALL InteractForm(l_settings)

END FUNCTION

 

Return to top

Built-In and Custom Actions

Invoking the built-in action looks as follows:

LET <InteractForm_Settings>.actions["<ActionScope>"]["<Event ID>"] = <call the function without any arguments>

When specifying a custom action, you must prefix the action identifier with the keywords ON ACTION.

Invoking a custom action:

LET <InteractForm_Settings>.actions["<ActionScope>"]["ON ACTION <Event ID>"] = <call the function without any arguments>

Example:

On the top level, we will have an active custom action with the identifier "Hello":

LET settings.actions["DIALOG"]["ON ACTION Hello"] = FUNCTION myfunc

Examples of the action / function reference mappings:

.actions["DIALOG"]["ON ACTION Hello"] = FUNCTION y

.actions["DIALOG"]["ON INSERT"] = FUNCTION z

.actions["INSERT"]["BEFORE INPUT"] = FUNCTION a

.actions["UPDATE"]["AFTER FIELD"] = FUNCTION b

.actions["ANY"]["AFTER INPUT"] = FUNCTION c

Note: Function references have no user-defined arguments (only a reference to the InteractForm will be passed as an argument).

 

Return to top

Disabling the Built-In Actions

If you set the function call to NULL, this will disable the corresponding built-in action. See the examples below:

LET settings.actions[""]["ON INSERT"] = NULL # Hide the INSERT action

LET settings.actions[""]["ON APPEND"] = NULL # Hide the APPEND action

LET settings.actions[""]["ON DELETE"] = NULL # Hide the DELETE action

LET settings.actions[""]["ON UPDATE"] = NULL # Hide the UPDATE action

 

Return to top

'actions_on_done': Arranging Custom Actions Execution After the Built-In Actions

The actions_on_done setting triggers the execution of a custom action after the built-in action:

LET settings.actions_on_done[""]["BEFORE DISPLAY"] = FUNCTION custom_func

This setting can be defined for:

InteractForm_Settings level: Yes

View level: Yes

 

Return to top

 

Using the ON CHANGE Clause With Lycia LowCode

To trigger the action with a change event, provide the fields for the ON CHANGE clause. There are four available options:

LET settings.views["contact"].actions["INSERT"]["ON CHANGE contact.cont_email" ] = FUNCTION my_function
LET settings.views["contact"].actions["INSERT"]["ON CHANGE contact.cont_fname, contact.cont_email" ] = FUNCTION my_function
LET settings.views["contact"].actions["INSERT"]["ON CHANGE *" ] = FUNCTION my_function
LET settings.actions[""]["ON CHANGE CURRENT ROW"] = FUNCTION my_function
Note: You can use the ON CHANGE clause with actions setting for a custom action execution before the built-in action, and with actions_on_done setting for a custom action execution after the built-in action.

 

Return to top

The Function Signature

For the function to be used as definition for the actions setting, and manage the built-in actions (or disable them), it must have one argument, receive the reference for current Lycia LowCode process record data (iform), and return the BOOLEAN status:

FUNCTION <function_name>(iform InteractForm INOUT) RETURNS BOOL

The function should return TRUE if it should prevent a built-in / predefined action processing, and it should return FALSE if it should not prevent built-in / predefined action.

Example:

FUNCTION custom_before_display(iform InteractForm INOUT) RETURNS BOOL

CALL fgl_winmessage("BEFORE DISPLAY")

RETURN FALSE # Process the custom action code first, and then the built-in action code.

END FUNCTION

 

Return to top

SQL Operations In Lycia LowCode

With Lycia LowCode, you can attach function calls to SQL operations.

SQL Operation LowCode's SQL Action Name
BEGIN WORK SQL BEGIN WORK
COMMIT WORK SQL COMMIT WORK
ROLLBACK WORK SQL ROLLBACK WORK
UPDATE SQL UPDATE
INSERT SQL INSERT
DELETE SQL DELETE

Choosing between the actions or actions_on_done settings defines whether your associated function reference should be called before the SQL operation is processed or after it is completed.

Examples:

LET settings.actions ["ANY"]["SQL BEGIN WORK"] = FUNCTION myFunc

LET settings.actions_on_done["ANY"]["SQL BEGIN WORK"] = FUNCTION myFunc

LET settings.actions ["ANY"]["SQL COMMIT WORK"] = FUNCTION myFunc

LET settings.actions_on_done["ANY"]["SQL COMMIT WORK"] = FUNCTION myFunc

LET settings.actions ["ANY"]["SQL ROLLBACK WORK"] = FUNCTION myFunc

LET settings.actions_on_done["ANY"]["SQL ROLLBACK WORK"] = FUNCTION myFunc

LET settings.actions ["ANY"]["SQL UPDATE"] = FUNCTION myFunc

LET settings.actions_on_done["ANY"]["SQL UPDATE"] = FUNCTION myFunc

LET settings.actions ["ANY"]["SQL INSERT"] = FUNCTION myFunc

LET settings.actions_on_done["ANY"]["SQL INSERT"] = FUNCTION myFunc

LET settings.actions ["ANY"]["SQL DELETE"] = FUNCTION myFunc

LET settings.actions_on_done["ANY"]["SQL DELETE"] = FUNCTION myFunc

 

Return to top

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.