INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

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!

RE: Disabling edit mode based on field value and user role

First of all, you are not calling the fields the right way :

CODE

If doc.roles(0) = "[TeamA]" Then
          if doc.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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close