Subject: RE: Check “QueryAccessRoles” method in LS (Checking the UserRoles of a variable that is a User)
Hi again
I don’t know of any way to do this in formula language, but it’s not to difficult with LS.
I’m assuming a notes client is being used, so set the “Exiting” on your field where you select the user name with the following script:
Sub Exiting(Source As Field)
'declaring variables
Dim session As New NotesSession
Dim db As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim docui As NotesUIDocument
'set the database
Set db = session.CurrentDatabase
'get a handle to the ui document
Set docui = ws.CurrentDocument
'get the name entered into the field “userSelect”
uName = docui.FieldGetText( “userSelect” )
'get the roles for that name
roles = db.QueryAccessRoles( uName )
'test if no roles,
If roles(0) = “” Then
msg = “No Roles”
Else
'else we have some roles so test them
Forall role In roles
msg = msg + role + Chr(10)
'or we can test for the role, and set a field value
If role = “[Admin]” Then
Call docui.fieldsettext( “varField1”, “1” )
End If
End Forall
End If
'set a field to display the string of roles.
Call docui.FieldSetText( “userRole”, msg )
End Sub
This was quickly done with field ‘userSelect’ as your selection field. ‘varfield1’ as a field to set a variable in. And ‘userRole’ as a computed text field, just to display the roles in testing mode. Using the ‘exiting’ event triggers the code to run when leaving the field.
HTH
andy G