Manage Learn to apply best practices and optimize your operations.

Versioning: Prevent Old Versions From Being Edited + Numbering + History

If you have had to deal with versioning you might have run into one or several
of the following questions:
1. How can I prevent previous versions of documents from being edited and allow
only the newest version to be changed?
2. How can I implement a revision number?
3. How can I implement a history functionality?
The following code shows how to implement all the above by using Notes' iternal
revision control (old versions become responses).
To achieve question 1:
Make the following changes on the form:
- Enable Versioning: "Prior version become responses"
- Create Versions: "Automatic - File, Save"
- Enable "Formulas inherit values from selected document"
- Add a field "DocumentID": Text, ComputedWhenComposed, Formula:
@Text(@DocumentUniqueID)

Querymodechange Event of the Form:
Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
If Not Source.Editmode Then
If Not source.document.Universalid = source.document.DocumentID(0)
Then Continue = False
End If
End Sub

Queryopen Event:
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant,
Continue As Variant)
If Source.Editmode And Not source.Isnewdoc Then
If Not source.document.Universalid = source.document.DocumentID(0)
Then Continue = False
End If
End Sub

Remark:
Be aware that this approach only restricts access through the UI and documents
may still be modified through the backend.

To achieve question 2:
Do the above, plus
- Add a field "Revision": Number, Computed, Formula: @If(@IsNewDoc | Revision
= "";0;Revision)

Querysave Event:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim curDoc As NotesDocument
Set curDoc = source.Document
If Not source.isnewdoc Then
curDoc.Revision = curDoc.Revision(0) + 1
End If
End Sub

To achieve question 3:
Do the above, plus
- Add a field "History": Text, Allow multi-values, Display separat values with:
New Line, computed when composed, Formula: History

Replace the existing Code in the Querysave Event with the following:
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim ses As New NotesSession
Dim curDoc As NotesDocument
Dim history() As String
Dim i As Integer, x As Integer

Set curDoc = source.Document
If Not source.isnewdoc Then
curDoc.Revision = curDoc.Revision(0) + 1
x% = Ubound(curDoc.History) + 1
Redim Preserve history( x%)
For i% = x% To 1 Step -1
history( i% ) = curDoc.History( i% - 1 )
Next
history( 0 ) = Format$(Now, "yyyy-mm-dd") + " : Edited by " +
ses.Commonusername
curDoc.History = history
Else
curDoc.History = Format$(Now, "yyyy-mm-dd") + " : Created by " +
ses.Commonusername
End If
End Sub

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com'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 ...

SearchDataCenter

SearchContentManagement

Close