@UserRoles in LotusScript

Hello. How do I use the formula, @IsMember(“[PDM]”;@UserRoles), in LotusScript? I’ve search this forum and could not find anything that could help me. Basically, I would like to use the QuerySave method on a form to check if the user has “[PDM]” role. If so, the “DateEdited” field should be computed to the current time/date. Otherwise, the field should not be modified. Any suggestions would be appreicated.

Subject: @UserRoles in LotusScript

Please find the following piece of code ::

Dim acl As NotesACL

Dim roleName As String

Dim foundRole As Variant

Set db = session.CurrentDatabase

Set acl = db.ACL

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

end if

Hope this helped you.

Cheers

Vinay

Subject: @UserRoles in LotusScript

You could also use something like:

dim hasRole as variant

hasRole = Evaluate(“@IsMember(”[PDM]“;@UserRoles)”, NotesDocument)

Shawn

Subject: RE: @UserRoles in LotusScript

Thanks everyone for all your responses. I’m not sure if all of your suggestions is what I’m looking for. Below is the code I’m using (or trying to use) in the QuerySave event and keep getting a ‘Type Mismatch’ error on the If-Then statement.

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim session As New NotesSession

Dim user As String

Dim hasRole As Variant

user = session.CommonUserName

hasRole = Evaluate(“@IsMember(”“[PDM]”“; @UserRoles)”)

If hasRole = True Then

  source.document.Date_Edited = Now

End If

End Sub

Subject: RE: @UserRoles in LotusScript

I an not so sure the evaluate will return the true/false that you are looking for but to get past the type mismatch, you need

If hasRole(0) = true

Subject: RE: @UserRoles in LotusScript

Tom, you’re right. I removed “= True” from the formula and it worked fine. The final code is below.

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim session As New NotesSession

Dim user As String

Dim hasRole As Variant

user = session.CommonUserName

hasRole = Evaluate(“@IsMember(”“[PDM]”“; @UserRoles)”)

If hasRole(0) Then

  source.document.Date_Edited = Now

End If

End Sub

Subject: RE: @UserRoles in LotusScript

Just a comment… the issue here should not have been the = True. if hasRole(0) Then and if hasRole(0) = True Then should evaluate the same.

Subject: @UserRoles in LotusScript

Take a look at the NotesACLEntry class - it has something like:

notesACLEntry.IsRoleEnabled( name$ )