Giving Users the Ability to Delete Documents of Known Types

Create roles for the two types of users that can exist. One role for Administrators that are able to delete any document from the database, and another for users who need to delete documents of a known type. In this case the documents were any existing orders - Form Type 'ORDFRM'. The two roles I created were '[rlDeleteAll]' & '[rlDeleteOrders]'. In the QueryDocumentDelete event in database script (found under 'other' in your design elements) I inserted the following code. (Users must have delete privledges in the ACL.)
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As 

Dim session As New NotesSession
Dim doc As NotesDocument
Dim i As Integer ' // 
Counter for number document to be deleted
Dim delOrders As Integer ' // Flag for 
check of user rights to delete orders
delOrders = 0

Const NotesMacro$ = "@UserRoles" ' // Gets a dynamic array of 
the user roles for current user
result = Evaluate(NotesMacro$, doc)

Set dc = Source.Documents ' // Collects only 
the documents marked for deletion

' // First check the roles to see if the user has the delete all role all document can be deleted
' // so simply return true for this user no matter what
For i = Lbound(result) To Ubound(result)
If result(i) = "[rlDeleteAll]" Then
Continue = True
Exit Sub
End If

' // Check to see if the user has roles to delete orders
For i = Lbound(result) To Ubound(result)
If result(i) = "[rlDeleteOrders]" Then
delOrders = 1
End If

' // User has no rights at all for deleting documents
If delOrders = 0 Then
Messagebox | Access Denied....
You do not have the required access to delete documents of any type.
Please see your system administrator to correct the problem. | 
Continue = False
Exit Sub
End If

' // While there are still documents to be deleted (documents in document collection)
For i = 1 To dc.Count
Set doc = dc.getNthDocument(i)
If doc.Form(0) = "ORDFRM" And delOrders = 1 Then
Continue = True
' // If any of the documents are not orders then we must deny deletion of all of them and 
' // display a message to the user saying that they do not have sufficient privileges to 
' // delete one or more of the documents
Continue = False
Messagebox | Access Denied....
You do not have sufficient rights to delete one or more of the selected documents |
Exit Sub
End If


End Sub

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...