Disabling edit mode based on field value and user role
Disabling edit mode based on field value and user role
(OP)
Hi!
I have a form that is accessible by different group which are assigned to different roles. On querymodechange, I would like to disable edit to the document if that status' field value is changed and of a particular role.
For example, edit IS possible if the value of Status field is "yes" and user's role is "[TeamA]". In a click of a button (found in the document), the Status' value changes to "No". At this point, user with role "[TeamA]" should NOT be able to edit the document. Also, the role is dependent to the value of Department field. So i still need to get the value of the Department field before I can identify the role of a user.
I've tried this script, but it always returns a error message "Type Mismatch":
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim deptRole As String
Dim depName As String
Dim entry As NotesACL
Dim item As NotesItem
Set db = s.CurrentDatabase
Set doc = New NotesDocument (db)
Set item = doc.GetItemValue ("DEPARTMENT_1")
depName = "[" & doc.department(0) & "]"
roles = db.QueryAccessRoles(session.UserName)
Forall r In entry.Roles
If roles(0) = "[TeamA]" Then
if status(0) <> "Yes" then
Messagebox "edit not allowed",, "Warning"
Continue = false
End Forall
End If
End If
End Forall
Please help.. Thanks so much!
I have a form that is accessible by different group which are assigned to different roles. On querymodechange, I would like to disable edit to the document if that status' field value is changed and of a particular role.
For example, edit IS possible if the value of Status field is "yes" and user's role is "[TeamA]". In a click of a button (found in the document), the Status' value changes to "No". At this point, user with role "[TeamA]" should NOT be able to edit the document. Also, the role is dependent to the value of Department field. So i still need to get the value of the Department field before I can identify the role of a user.
I've tried this script, but it always returns a error message "Type Mismatch":
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim deptRole As String
Dim depName As String
Dim entry As NotesACL
Dim item As NotesItem
Set db = s.CurrentDatabase
Set doc = New NotesDocument (db)
Set item = doc.GetItemValue ("DEPARTMENT_1")
depName = "[" & doc.department(0) & "]"
roles = db.QueryAccessRoles(session.UserName)
Forall r In entry.Roles
If roles(0) = "[TeamA]" Then
if status(0) <> "Yes" then
Messagebox "edit not allowed",, "Warning"
Continue = false
End Forall
End If
End If
End Forall
Please help.. Thanks so much!
RE: Disabling edit mode based on field value and user role
CODE
if doc.status(0) <> "Yes" then
Messagebox "edit not allowed",, "Warning"
Continue = false
End Forall
End If
CODE
You don't want to work on a new document, you want to work on the current document, which should be accessible via the UIdocument object in the QueryChange event of the form, or directly via the NotesDocument object in the QueryOpen event of the form.
Which is where you put the code, right ?
Pascal.
I've got nothing to hide, and I'd very much like to keep that away from prying eyes.