Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling edit mode based on field value and user role

Status
Not open for further replies.

gem28

Instructor
Nov 5, 2001
64
PH
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!
 
First of all, you are not calling the fields the right way :
Code:
If [b]doc.[/b]roles(0) = "[TeamA]" Then
          if [b]doc.[/b]status(0) <> "Yes" then
        Messagebox "edit not allowed",, "Warning"
            Continue = false
        End Forall
           End If
Second, you declare
Code:
Set doc = New NotesDocument (db)
and that means that you're working on a new document - which doesn't have any fields.

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top