Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Want to thank those people who have made this forum such a valuable place to visit each day..."

Geography

Where in the world do Tek-Tips members come from?

Disabling edit mode based on field value and user role

gem28 (Instructor)
1 Dec 06 2:28
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!
pmonett (Programmer)
1 Dec 06 5:11
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.

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!

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