Manage Learn to apply best practices and optimize your operations.

Prevent users from editing through the UI

How to allow a user to modify a document without having them change it by putting it in Edit mode.

View expert feedback to this tip.

There may be occasions where a user needs to be able to modify a document but you don't want them to change it by putting the document in Edit mode. This method requires changes to an action button as well as two form events.
In the Form Globals Declarations,
Dim EditAction As Variant
Then, in an Edit action button:
Initialize event:
EditAction = True
Terminate event:
EditAction = False
The Click event can contain checks
 to enable certain users to switch to 
edit mode (by setting NotesUIDocument.
EditMode = True) and/or messages
 regarding how to change the document.
Sub Queryopen(Source As 
Notesuidocument, Mode As Integer, 
Isnewdoc As Variant, 
Continue As Variant)
If Not Isnewdoc Then
 If Source.EditMode Then
  Messagebox "This document cannot 
be opened in Edit mode",16,"Edit 
  Continue = False
 End If
End If
End Sub
Sub Querymodechange(Source As 
Notesuidocument, Continue As Variant)
If Not EditAction Then
 Messagebox "You must use the Edit 
action button to edit the document",
 Continue = False
'An alternate place for code that allows 
certain users to edit. To disallow edits, 
make Continue = False
End If
End Sub


This is not really secure. The only guaranteed secure way to control who can edit a document is to use Authors fields. There are several ways to bypass this LotusScript control. The simplest is to write an agent or smarticon formula to assign whichever fields you want to assign. Anyone with Domino Designer can also use the LotusScript debug mode to prevent execution of this code (start to debug it and click "Stop").

Considering that the stated purposes of this edit action button could be better satisfied using an Authors field (if the idea is to only let certain users edit) and/or by putting message boxes in the Querymodechange and Queryopen code (if the purpose is to display "messages regarding how to change the document").

Do you have comments of your own? Let us know.

Dig Deeper on LotusScript



  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury