Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stop deleletion

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
here it is:

I have a group that has EDITOR+DELETION rights

can can I stop them from deleting certain documents. Can someone please provide me with some LS that does this, I know where the script goes but dont know how to write it

many thnks
 
Hello newt3!

What you're going to have to do is put some code in your Database Script (Under Design....Other) for the QueryDocumentDelete code.

The first thing you have to determine is... how you want to determine which documents do and don't get deleted. If they're based off a certain form, it's easy- just use the form's name. Here's some sample code:
Code:
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
     Dim CurDoc As NotesDocument
     Set CurDoc = Source.Document
     If CurDoc.Form( 0 ) = "formName" Then
          Continue = False
          Msgbox "You cannot delete these documents!"
     End If
End Sub

What I like to do, futher than that, is to check on who is trying to delete it, and if they're not a member of a certain role, not allow it. For instance, I usually have 2 specific roles in my databases - [ADMIN] and [SERVER]. The ADMIN role is for any database administrators that have full access to all functionalities of the DB. The SERVER role is set up so that EVERY DOCUMENT that has a Authors Field (populated) and Readers field (populated) will always have SERVER in both- for replication and agent abilities, as well as name changes, etc. etc...

Anyhow, here's how I would change the above code to allow only those groups...

Code:
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
     Dim DocCol As NotesDocumentCollection  ' To hold all selected documents
     Dim CurDoc As NotesDocument                            ' For cycling through documents in DocCol
     
     Dim vEvalResp As Variant   ' Used for determining if user is part of correct role
     
     ' Find out if the user is not a member of either Admin, or Server roles.
     vEvalResp = Evaluate( |!@IsNotMember(@UserRoles; "[ADMIN]":"[SERVER]")| )
     If vEvalResp( 0 ) Then Exit Sub ' If they are a member, then leave module
     
     Set DocCol = Source.Documents  ' This are documents selected in the view.
     
     Set CurDoc = DocCol.GetFirstDocument
     Do Until CurDoc Is Nothing ' Cycle through all documents in DocCol
          If CurDoc.Form( 0 ) = "MyForm" Then ' If the selected form is of type "MyForm" then fail
               Continue = False ' Tell Notes that we are not going to delete the doc.
               Exit Do
          End If
          Set CurDoc = DocCol.GetNextDocument( CurDoc )
     Loop
     
     If Continue = True Then
          Msgbox "You do not have access to delete one or more of the selected documents!", 48, "Error deleting documents"
     End If
CleanUp:
     Set DB = Nothing
     Set DocCol = Nothing
     Set CurDoc = Nothing
End Sub
 
Ooops, GOOFED! Don't believe that first code block, it's wrong (Source is not a NotesUIDocument as I had planned. heh, serves me right for not testing!)

Anyhow, this would be your first block, to dis-allow ANYONE from deleting a document of type "formName":

Code:
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
     Dim DocCol As NotesDocumentCollection  ' To hold all selected documents
     Dim CurDoc As NotesDocument  ' For cycling through documents in DocCol
     
     Set DocCol = Source.Documents  ' This are documents selected in the view.
     Set CurDoc = DocCol.GetFirstDocument
     Do Until CurDoc Is Nothing ' Cycle through all documents in DocCol
          If CurDoc.Form( 0 ) = "formName" Then ' If the selected form is of type "formName" then fail
               Continue = False ' Tell Notes that we are not going to delete the doc.
               Exit Do
          End If
          Set CurDoc = DocCol.GetNextDocument( CurDoc )
     Loop
     
     If Continue = True Then
          Msgbox "You do not have access to delete one or more of the selected documents!", 48, "Error deleting documents"
     End If
     
CleanUp:
     Set DB = Nothing
     Set DocCol = Nothing
     Set CurDoc = Nothing
End Sub
 
Ooops, GOOFED! Don't believe that first code block, it's wrong (Source is not a NotesUIDocument as I had planned. heh, serves me right for not testing!)

Anyhow, this would be your first block, to dis-allow ANYONE from deleting a document of type "formName":

Code:
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
     Dim DocCol As NotesDocumentCollection  ' To hold all selected documents
     Dim CurDoc As NotesDocument  ' For cycling through documents in DocCol
     
     Set DocCol = Source.Documents  ' This are documents selected in the view.
     Set CurDoc = DocCol.GetFirstDocument
     Do Until CurDoc Is Nothing ' Cycle through all documents in DocCol
          If CurDoc.Form( 0 ) = "formName" Then ' If the selected form is of type "formName" then fail
               Continue = False ' Tell Notes that we are not going to delete the doc.
               Exit Do
          End If
          Set CurDoc = DocCol.GetNextDocument( CurDoc )
     Loop
     
     If Continue = False Then
          Msgbox "You do not have access to delete one or more of the selected documents!", 48, "Error deleting documents"
     End If
     
CleanUp:
     Set DB = Nothing
     Set DocCol = Nothing
     Set CurDoc = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top