Cancel a user's delete action.
When one or more records are selected from databox and a DELETE event occurred (from menu or from
toolbar) then a special xojoscript is invoked before
deletion.
From that script one can call AbortDelete in order to cancel the deletion
of a record from 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
deletion of records with open invoices.
Parameters
:
Name |
Value |
Description |
action |
"TRUE" |
Cancel deletion of a record |
"YES" |
Cancel deletion of a record |
|
"FALSE" |
Allow deletion of a record |
|
"*" |
Any String other than
"TRUE" or "YES": Allow deletion of a record |
Available in:
WindowMain |
WindowLink |
YES |
NO |
Used in:
XojoScript
Name |
GUID |
Record delete from databox
|
E8AC18FC-3956-42B8-AF94-86CF7FA5B10E |
Example Code:
Dim modul
As String = GetActiveModul
// Prevent deletion of addresses if there are open seminar
invoices
If modul
= "addresses" Then
Dim arID()
As string
arID
= IDArrayOfSelectedAddresses
// If the passed array has no elements, result
is set to -1.
If
Ubound(arID) > -1 Then
Dim idStr
As String
idStr
= Join(arID,","
)
Dim sql
As String
sql
= "SELECT count(*) 'openbills'
" _
+ "FROM " + GetPrefix + "link_adr_evt lnk, " + GetPrefix + "addresses
adr " _
+ "WHERE lnk.id_adr = adr.id " _
+ "AND adr.id IN ("
+ idStr + ") "
_
+ "AND totalpaid
NOT LIKE groupprice"
Dim Records() As
String
Dim FieldDelimiter
As String = "**"
// Store Results in Array
Records = SQLSelect
(sql,FieldDelimiter)
// Proceed if we have received any records
If
Ubound(Records)
> -1 Then
// If we produced an error, the returning
record
// starts with the String : "ERROR"
If
Left(Records(0 ),5 )="ERROR"
Then
MsgBox Records(0 ) // Display warning
Else
Dim StrOpenBills
As String
Dim NumOpenBills
As Integer
// Number of open bills found
StrOpenBills
= NthField(records(0
),FieldDelimiter,1 )
NumOpenBills
= Val(StrOpenBills)
If
NumOpenBills
> 0 Then
MsgBox ("Deletion was canceled!" + EOL + EOL + "Open invoices found: " + StrOpenBills)
AbortDelete ("TRUE" )
Else
AbortDelete ("FALSE" )
End If
// NumOpenBills > 0
End If
//
Left(Records(0),5)="ERROR"
End If
// Ubound(Records) > -1
End If
// Ubound(arID) > -1
End If // modul = "addresses