How to block edit document from main view

Discussion in 'Lotus Notes General Discussion' started by Michael Reinders, Feb 10, 2006.

  1. I have a custom database set so that only documents in specific
    categories can be edited. If they are in the other list of categories,
    they cannot edit the doc (I've added code to the form under the
    QueryModeChange object:

    If Not ( source.EditMode ) Then
    currentStatus = source.FieldGetText( "Categories" )
    If ( currentStatus <> "Drafts" ) Then
    Messagebox ( "This document has been Marked Final and can not be
    edited." )
    continue = False
    End If
    End If

    That works fine. I also removed Actions, Edit Document from the menu in
    the database. The only thing I'm working on is the CTRL-E key sequence.
    I know I can't 'block' it but I need to add code to the effect if a
    user is in the main view of the db, and presses Ctrl-E, and they are
    NOT listed in the authors field I created on the form, then a message
    will pop up just like the code under QMC and close the document
    automatically.

    Can I use QueryOpen to accomplish this, or would this adversely affect
    users if they open any document the normal way? Or could I use code
    something like this in QueryOpen:

    If Isnewdoc Then Exit Sub
    Set note = source.document
    If "authors" = "Admin/c-g" Then
    continue = False
    End If

    I don't think I have the syntax right, but do you catch my drift?

    Thanks for all your help. I NEED to make this work asap!

    Michael
     
    Michael Reinders, Feb 10, 2006
    #1
    1. Advertisements

  2. Michael Reinders

    Joep8020 Guest

    Michael

    There are two ways to accomplish this:
    1) put the code in the postopen (in this code you'll have to set
    source.EditMode to false)
    if source.EditMode then
    if source.Document.Categories(0)<>"Drafts" then
    source.Document.SaveOptions="0"
    source.EditMode=false
    end if
    2) put the code in the QueryOpenDocument (of the view)
    if source.Documents.GetFirstDocument.Categories(0)<>"Drafts" then
    Continue=false
    end if


    However a caveat!!! A user can circumvent this security in several
    ways:
    1) Create an agent to make changes
    2) Enable the Script Debugger, and when entering the event press the
    Stop button. The code will nit be excecuted, and the normal behaviour
    takes over



    Michael Reinders schreef:
     
    Joep8020, Feb 20, 2006
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.