I have posted this in lotus script. No one reply to my previous message. I converted from lotusscript to formula to make it work faster.
Unfortunately formula does not work, it only prompt me for Manager role and put document to edit mode. No matter what role I assign to myself. Please help with this request.
man:=@IsMember(“[Manager]”;@UserRoles);“”;@Return(@Prompt([Ok];“Access Denied”; “You are not authorized Manager to Edit documents.”));
neu:=@IsMember(“[Neur]”;@UserRoles);“”;@Return(@Prompt([Ok];“Access Denied”; “You are not authorized to Edit NEUR documents.”));
onc:=@IsMember(“[Oncol]”;@UserRoles);“”;@Return(@Prompt([Ok];“Access Denied”; “You are not authorized to Edit ONC documents.”));
pem:=@IsMember(“[Premi]”;@UserRoles);“”;@Return(@Prompt([Ok];“Access Denied”; “You are not authorized to Edit PREM documents.”));
fron:=@IsMember(“[Front”;@UserRoles);“”;@Return(@Prompt([Ok];“Access Denied”; “You are not authorized to Edit FRONT documents.”));
This would be much easier if you created author fields with the relevant role in them
Your formula is strange though, you’re not using @if to check each of the variables, so you just get to the first prompt and stop. You need
man:=@if(@IsMember(“[Manager]”;@UserRoles);“”;@Return(@Prompt([Ok];“Access Denied”; “You are not authorized Manager to Edit documents.”)));
etc.
This isn’t foolproof though - I’m assuming you have this in your querymodechange event (you don’t say and I didn’t see your first post).
Querymodechange events can be bypassed by a user hitting Ctrl+E from the view - the document will just open in edit mode. That’s why you need author fields
The use of an authors field would be the correct way… Just add the roles with between into a multivalue.
If you have to do it by script use this:
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Dim vCheckMgr As Variant, vCheckEdit as variant 'specify more if needed
continue=false
vCheckMgr = Evaluate({@IsMember("[Manager]";@UserRoles)})
vCheckEdit = Evaluate({@IsMember("[Editor]";@UserRoles)})
If Isnewdoc then 'remove it not needed
continue=true
Exit Sub
End if
If not Mode then 'if only opened for reading let it be
continue = true
End if
If vCheckMgr(0) Then
Print "Manager Role found - Access granted"
Elseif vCheckEdit(0)
Print "Editor Role found - Access granted"
'...here you can add more elseifs...
Else
Messagebox "You do not have the any role that allowes you to edit this document",16,"[Info]"
End If
End Sub
Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
Dim vCheckMgr As Variant, vCheckEdit as variant 'specify more if needed
continue=false
vCheckMgr = Evaluate({@IsMember("[Manager]";@UserRoles)})
vCheckEdit = Evaluate({@IsMember("[Editor]";@UserRoles)})
If vCheckMgr(0) Then
Print "Manager Role found - Access Granted"
continue = true
If vCheckEditor(0) Then
Print "Editor Role found - Access Granted"
continue = true
Elseif source.EditMode Then
'doc already was in Edit Mode
continue = true
Else
Messagebox "You do not have the any role that allowes you to edit this document",16,"[Info]"
End If