Tip

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"
Else
AllowEdit "False"
End If
Else
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

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.