This code computes and displays the modification history of a document. The document must contain a field (mine is hidden) called HIDDENHISTORY, an editable text list field. This field takes holds the edit history. Use as you would any class.
I put this code in the QuerySave event where "doc" is a global variable defined in the form's global declarations and assigned in the postopen event:
Dim modify As New Modification
modify.ModifyHiddenHistory doc
This code is in a form action button pressed to display the modification history:
Dim modify As New Modification
modify.ModHistory
Code
Class Modification
'---Stowe Spivey, November 29, 2001
Function numtosee '---how many modifications do you wnat to see in the
messagebox
numtosee=12
End Function
Sub ModifyHiddenHistory(doc As NotesDocument)
Dim session1 As New NotesSession
Dim dateTime As New NotesDateTime( "" )
Dim item As NotesItem
Set item=doc.GetFirstItem("HiddenHistory")
dateTime.LSLocalTime = Now
item.AppendToTextList session1.CommonUserName & " " &
dateTime.LSLocalTime & ";"
doc.Save True, False
End Sub
Sub ModHistory
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim upper As Integer
Dim lower As Integer
Dim history As String
Dim ending As String
Dim havehas As String
Set uidoc=ws.Currentdocument
Set doc=uidoc.Document
updaters = doc.getitemvalue("HiddenHistory")
upper=Ubound(updaters)
If upper < (numtosee - 1) Then
lower=0
Else
lower=upper - numtosee + 1
'adding 1 takes into account the counting of the first item
End If
history=""
For i = upper To lower Step -1
history=history & updaters(i) & Chr(10)
Next i
If upper > 0 Then '---customizes the output to plural if needed.
ending = "s"
havehas = "have"
Else
ending=""
havehas = "has"
End If
Messagebox history, 64, "There "& havehas &" been " & upper
+ 1 & " modification" & ending & ". Following are the most recent
" & upper - lower + 1
End Sub
End Class