Manage Learn to apply best practices and optimize your operations.

Allowing Access To Form Based On Field

The reason I originally wrote this code is so the user could not edit a
document once it was submitted for approval. The user still needed to edit the
document so that they could approve the document but not allow them to change
anything else.

Process: Allowing a document to be editable as normal when the value of a
field is Draft. Once the value is anything other than draft then an
environment variable is read to see if the document can be edited. The reason
for the environment variable is so that code can still edit the document to
update information when approving or adding a comment.
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant,
Continue As Variant)
AllowEditByDocField Source.Document, "Status", "Draft"
End Sub
Sub Postopen(Source As Notesuidocument)
AllowEditByDocField Source.Document, "Status", "Draft"
End Sub
Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
Continue = AllowEditQueryModeChange ( Source, "Status" , "Draft" )
End Sub
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
AllowEdit "True"
End Sub

Sub AllowEditByDocField( Source As NotesDocument, Field As String, Value As
String )
'Setting flag that does not let the user put the document into edit mode.
'If the Source is nothing then the source is a new document so allow into
edit mode.
If Not Source Is Nothing Then
Dim Item As NotesItem
Set Item = Source.GetFirstItem( Field )
If Item.Text = Value Then
AllowEdit "True"
AllowEdit "False"
End If
AllowEdit "True"
End If
End Sub

Function AllowEditQueryModeChange ( Source As notesUIDocument , Field As
String, Value As String )
AllowEditQueryModeChange = True
'The only time that the document should be edited is when the docuemnt is
still in "draft" or what ever value is based in by value mode.
If GetAllowEdit = "True" Then
AllowEditQueryModeChange = True
Elseif Source.FieldGetText( Field ) <> value And Not ( Source.EditMode
) Then
Messagebox "Once the " & Source.FieldGetText( "Form" )& " has been
submitted no changes can be made.", 64 , "Unable to edit."
AllowEditQueryModeChange = False
End If
End Function

Function GetAllowEdit
Dim Session As New NotesSession
GetAllowEdit = Session.GetEnvironmentString ( "AllowEdit" )
End Function

Sub AllowEdit ( State As String)
Dim Session As New NotesSession
Session.SetEnvironmentVar "AllowEdit", State
End Sub

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...