dbxDataEvent_tableName_SetDefaultValues
Function called to initialize the record with default values.
Syntax
PUBLIC FUNCTION dbxDataEvent_tableName_SetDefaultValues(
p_data record-type)
RETURNS (record-type)
The function has the following parameter:
p_data
. This is aRECORD
type defined according to the structure of the database table.
- record-type. This is a
RECORD
type defined according to the structure of the database table.
Usage
When you select the Set Default Values property for the creation of the event, a function shell is created. Enter your code in the function.
This function is called to initialize business records with default values. For a Form, it is called when a new row is created. For a CRUD Web Service, it is called before initializing a field in the business record. You use it if you want to add a default value for a field that does not have a default value defined in the database schema, or if you want to change the default value defined in the database schema.
Example: Set Default Values
This example uses the Set Default Values event for the Account table in the OfficeStore demo.
In this example, the value for the "langpref" field is set to "English". As a result, the default
value is set for this field in the form by the return record p_data
.
PUBLIC FUNCTION dbxDataEvent_account_SetDefaultValues(p_data RECORD LIKE account.*)
RETURNS (RECORD LIKE account.*)
CALL libdbappCore.log(C_LOG_INFO, "dbx dataEvent_account_SetDefaultValues (Table scope) is raised")
LET p_data.langpref = "English"
CALL libdbappCore.log(C_LOG_INFO, "dbx dataEvent_account_SetDefaultValues (Table scope) is exited")
RETURN p_data.*
END FUNCTION
For more information on the libdbappCore.log()
function,
go to DBAPPDEBUG and the debug level API.