I am very new to LS, and I am facing a problem that I cannot solve. In the QueryModeChange I have this simple code:
Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim uidoc As NotesUIDocument
Dim acl As NotesACL
Dim entry As NotesACLEntry
Set db = session.CurrentDatabase
Set acl = db.ACL
Set entry = acl.GetEntry( session.CommonUserName )
If entry Is Nothing Then
Set entry = acl.GetEntry( session.UserName )
End If
If entry.IsRoleEnabled( "[utilisateur]" ) Then
If Source.FieldGetText("stt") = "Approbation" Then
Messagebox "Cette demande a été soumise pour approbation, elle ne peut plus être modifié"
continue = False
End If
End If
End Sub
This code make sure that a user cannot modify the form on a certain conditions.
I’m getting this error: “Object variable not set” if I do not have the role “utilisateur”.
I do not have this error if I have the role “utilisateur”.
Subject: Error in my LS code in the QuerymodeChange
Hi
1st)
Syntax
flag = notesACLEntry.IsRoleEnabled( name$ )
Parameter
name$
String. The name of the role. The recommended style is to use just the name, with no parentheses or square brackets around it. If square brackets surround the name, they will be stripped and the enclosed name used.
So remove the brackets first.
2nd)
The error may be somewhere else, if you tried it with an already approved doc (you did not tell about the value of ‘stt’…!)
Continue your tests with an ‘else’ section after your ‘continue=false’ line, displaying a message box…
Subject: Error in my LS code in the QuerymodeChange
Hi,
For checking UserRoles I prefer Evaluate:
Sub sQuerymodechange(Source As Notesuidocument, Continue As Variant)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim vUserRoles As Variant
Dim isUtilisateur As Boolean
isUtilisateur = False
vUserRoles = Evaluate ( "@UserRoles", source.Document )
If Isarray( vUserRoles ) Then
Forall role In vUserRoles
If role = "[utilisateur]" Then isUtilisateur = True
End Forall
End If
If isUtilisateur Then
If Source.FieldGetText("stt") = "Approbation" Then
Messagebox "Cette demande a été soumise pour approbation, elle ne peut plus être modifié"
continue = False
End If
End If
End Sub
If it doesnt work for you, please post on which Line you get the “Object variable not set” Error.
If you are not by your name in the ACL, but as a groupmember, and the role is granted to the group, you have no chance of recognizing you have the rule.
@UserRoles always calculates that, so Evaluating it is a good shortcut.