Description
The CustomAdd event is executed before the record is physically added to the database. It is designed to replace the standard Add procedure.
Use it when you do not want record to be added to the table in question.
Syntax
CustomAdd(values, keys, error, inline, pageObject)
Arguments
Note: Field names are case-sensitive. If the field name is PlayerId, you should use values("PlayerId"). Note that values("playerid") or values("PlayerID") will not work.
Note: If the field was assigned an alias in the SQL query, then the values array will get the alias instead of the field name from the database.
E.g., if you have an SQL query SELECT salesrep_id AS Inv_Salesrep ..., you should use values["Inv_Salesrep"].
values
an array of values to be written to the database. To access a specific field value, use values("FieldName").
keys
an array of key column values that point to the new record. To access a specific key column, use keys["KeyFieldName"].
error
place the message to be displayed into this variable.
inline
equals to '1' for the Inline Add, '0' otherwise.
pageObject
an object representing the current page. For more information, see RunnerPage class.
Return value
True: if you want the application to handle adding the record.
False: if you have added the record with your code.
Applies to pages
Add, Inline Add.
Example
Lets consider the situation when records are never added directly to the main table (e.g., Cars).
Instead, records are added to the temporary TempCars table and then moved to the main Cars table once approved by the admin.
In this case, the following code in the CustomAdd event will do the job:
dal.Table("TempCars").Value("make")=values("make")
dal.Table("TempCars").Value("model")=values("model")
dal.Table("TempCars").Value("yearOfMake")=values("yes")
dal.Table("TempCars").Add()
CustomAdd=false
Note: You may have noticed that the BeforeAdd event does the similar job. The main difference is that returning false in the BeforeAdd event is considered an error, and the user will see that something went wrong. Returning false in the CustomAdd event is perfectly legitimate, and application execution continues after that.
See also:
•How to control Inline Add/Edit functionality from script
•Javascript API: InlineRow object