AbortInsert(action As String)

 

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

"TRUE"

Cancel insertion of a record

 

"YES"

Cancel insertion of a record

 

"FALSE"

Allow insertion of a record

 

"*"

Any String other than "TRUE" or "YES":

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("TRUE")

Return

 

End If  // lastname = "" And company = ""

End If // ActiveModul = addresses

End If // IsInsertMode