Cancel a user's insert action.
When a SAVE event occurred (from menu or from toolbar) then a special xojoscript is invoked before alteration of an existing record.
From that script one can call AbortUpdate in order to cancel the alteration of an existing record in databox. Special scripts run before occurance of an Insert, Update or Delete to the database. See menu 'Script -> Edit Special Scripts'.
From such a script we can implement customer specific business rules, like not allowing saving of records with incomplete data.
Parameters:
Name |
Value |
Description |
action |
"TRUE" |
Cancel alteration of a record |
|
"YES" |
Cancel alteration of a record |
|
"FALSE" |
Allow alteration of a record |
|
"*" |
Any String other than "TRUE" or "YES": Allow alteration of a record |
Available in:
WindowMain |
WindowLink |
YES |
NO |
Used in:
XojoScript Name |
GUID |
Record update in databox |
4A25A881-0947-45EF-B691-B81900C1ACEE |
Example Code:
If (IsEditMode = 1) Then
Dim modul As String = GetActiveModul
If modul = "addresses" Then
Dim company As String = GetText("imTF_adr_OrganizationName")
Dim lastname As String = GetText("imTF_adr_LastName")
// Either one must be filled out, abort if empty
If lastname = "" And company = "" Then
MsgBox("Please fill out either 'Lastname' or 'Company'." + EOL + EOL + "This record has not been saved.")
// Cancel Saving of data
AbortUpdate("TRUE")
Return
End If // lastname = "" And company = ""
End If // ActiveModul = addresses
End If // IsEditMode Or IsInsertMode