- This script prevents the user from creating a new document.
Sub Queryopen(Source As Notesuidocument, _
Mode As Integer, _
Isnewdoc As Variant, Continue As Variant)
If IsNewDoc Then
Messagebox _
( "Only one Setup document is permitted" )
continue = False
End If
End Sub
- This script prevents the user from creating a Setup document if
one already exists in the database. When the user tries to create
a new document, the script checks whether there is a document in the
Setup view. If so, a Setup document already exists in the database
and the user is prevented from creating another one.
Sub Queryopen(Source As Notesuidocument, _
Mode As Integer, _
Isnewdoc As Variant, Continue As Variant)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
' Check if the user is trying to create a new Setup doc
If IsNewDoc Then
Set db = session.CurrentDatabase
Set view = db.GetView( "Setup" )
Set doc = view.GetFirstDocument
' Check if a Setup doc already exists in the db
If Not ( doc Is Nothing ) Then
Messagebox _
("Only one Setup document permitted.")
' If so, don't let user create another one
continue = False
End If
End If
End Sub
- This script checks whether the user has a Supervisor role in the
ACL. If so, the user can open the document; if not, or if the user
is not listed in the access control list, the user cannot open the
document.
Sub Queryopen(Source As Notesuidocument, _
Mode As Integer, _
Isnewdoc As Variant, Continue As Variant)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim acl As NotesACL
Dim entry As NotesACLEntry
Set db = session.CurrentDatabase
Set acl = db.ACL
Set entry = acl.GetEntry( session.UserName )
If ( entry Is Nothing ) Then
continue = False
Elseif Not ( entry.IsRoleEnabled( "Supervisor" ) ) Then
continue = False
End If
End Sub