Cancel a user's insert action.
When a SAVE event occurred (from menu or from toolbar) then
a special xojoscript is invoked before insertion of a
new record.
From that script one can call AbortInsert in order to cancel the
insertion of a new 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 insertion of records with incomplete data.
Parameters
:
Name |
Value |
Description |
action |
1 |
Cancel insertion of a record |
0 |
Allow insertion of a record |
Available in:
WindowMain |
WindowLink |
YES |
NO |
Used in:
XojoScript
Name |
GUID |
Record insert in databox |
C05B0C75-E449-4752-AB16-65693A6A00A1 |
Example Code:
If (IsInsertMode = 1 ) Then
If
GetActiveModul
= "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
AbortInsert (1 )
Return
End If
// lastname =
"" And company = ""
End If
// ActiveModul =
addresses
End If // IsInsertMode