Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Table events > Edit page

Custom record update

Scroll Prev Next More

Description

The CustomEdit event is executed before the data record is updated in the database. It is designed to replace the standard Edit procedure.

 

Use it when you do not want record to be updated in the table in question.

Syntax

public XVar CustomEdit(dynamic values, dynamic where, dynamic oldvalues, dynamic keys, dynamic error, dynamic inline, dynamic 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"].

where

WHERE clause that points to the edited record. Example: ID=19.

oldvalues

array with existing field values. To access a specific column value, use oldvalues["FieldName"].

keys

an array of key column values that point to the edited record. To access a specific key column, use keys["KeyFieldName"].

error

place the message to be displayed into this variable.

inline

equals to true for the Inline Edit, false otherwise.

pageObject

an object representing the current page. For more information, see RunnerPage class.

Return value

True: if you want the application to handle updating the record.

 

False: if you have updated the record with your code.

Applies to pages

Edit, Inline Edit.

Example

Lets consider the situation when records are never edited directly in 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 admin.

 

In this case the following code in the CustomAdd event will do the job:

 

dynamic tblTempCars = GlobalVars.dal.Table("TempCars");
tblTempCars.Value["make"] = values["make"];
tblTempCars.Value["model"] = values["model"];
tblTempCars.Value["yearOfMake"] = values["yearOfMake"];
tblTempCars.Add();
return false;

See also:

How to control Inline Add/Edit functionality from script

Javascript API: InlineRow object

Choose pages screen

About SQLQuery class

About SQLQuery screen

Additional WHERE tabs

User group permissions

DAL method: Add()

Before record update

After record updated