This script lets the user enter a role name into a dialog box.
The script then displays the name of each entry for which the role
is enabled in a field (called People) on the current document. The
script adds brackets to the role name that the user enters, and then
uses the Roles property to make sure that the name exists in the current
database. If not, an error message is displayed; if so, the script
continues.Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim session As New NotesSession
Dim db As NotesDatabase
Dim acl As NotesACL
Dim entry As NotesACLEntry
Dim roleName As String
Dim foundRole As Variant
Set uidoc = workspace.CurrentDocument
Set db = session.CurrentDatabase
Set acl = db.ACL
roleName = Inputbox$( "Enter the name of the role" )
' add brackets to role
roleName = "[" & roleName & "]"
foundRole = False
' check to see if the role exists in the database
Forall r In acl.Roles
If ( r = roleName ) Then
foundRole = True
Exit Forall
End If
End Forall
If NOT foundRole Then
Messagebox _
( "Sorry, " & roleName & " is not a role" )
' if the role exists, check each acl entry to see if role
' is enabled for entry
' if so, add entry name to the People field
' on the current document,
' followed by a semicolon, the multi-value separator
Else
Set entry = acl.GetFirstEntry
While Not ( entry Is Nothing )
If entry.IsRoleEnabled( roleName ) Then
Call uidoc.FieldAppendText _
( "People", entry.Name & ";" )
End If
Set entry = acl.GetNextEntry( entry )
Wend
End If
' refresh current document so People field displays nicely
Call uidoc.Refresh