About This Code
Brief Description:
History Class for documents
Contributor:
Michael Woehrer/Woehrer
Type:
Document Management
Notes Version:
R5.x, R6.x
Last Modified:
16 Oct 2004
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
------------------------------------------------------------------------------------
<b>PURPOSE</b>
------------------------------------------------------------------------------------
This history class observes changes of a UI document and writes these changes into a history field.
(item name: see constants, default is 'History')
In addition can you use this class to add an entry in the backend (e.g. if you change the status of a document) or to empty the history field.
The history field itself must be of type "text", allow multiple values, computed when composed, display separate values with 'New Line'.
The 'columns' are separated via tabulator (chr(9)); so put the field below a table or a text (separated by tabs) with the following header:
Date | User | Changes
------------------------------------------------------------------------------------
[b]CREATION[/b]
------------------------------------------------------------------------------------
Dim variableName As New History
OR
Dim variableName As History
Set variableName = New History
------------------------------------------------------------------------------------
[b]METHODS[/b]
------------------------------------------------------------------------------------
[b]Method:[/b]
PostopenStartObservation
[b]Syntax:[/b]
Call PostopenObserve(NotesUIDocument, Variant-Array of Itemnames)
[b]Description:[/b]
Starts the observation of a document, which means that this method observes every (via Variant-Array of Itemnames provided) field.
The PostSave and the Querymodechange-Events are also observed by this method. If changes in a document occured, the history will be updated (in the PostSave-event).
[b]Usage:[/b]
*exclusively* in the Postopen-Event of a form
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[b]Method:[/b]
AddEntry
[b]Syntax:[/b]
Call history.AddEntry (NotesDocument, StringToAdd$)
[b]Description:[/b]
Adds a new entry to the history field (using current date/time and session.Username)
[b]Usage:[/b]
Use this backend-method if you want to add a new entry, e.g. if you change the status of a document programmatically, you can add a new line with the text "Changed status to pending."
This method does *not* save the NotesDocument.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[b]Method:[/b]
Empty
[b]Syntax:[/b]
Call history.Empty(NotesDocument)
[b]Description:[/b]
Remove the content of the history field.
[b]Usage:[/b]
Use this backend-method if you want to empty the history field.
This method does *not* save the NotesDocument.
------------------------------------------------------------------------------------
[b]PROPERTIES[/b]
------------------------------------------------------------------------------------
[b]Property:[/b]
MaxEntries
[b]Type:[/b]
SET
[b]Syntax:[/b]
history.MaxEntries = intMaxEntries
[b]Description:[/b]
Maximum entries in the history field. Default = 20 (see constant "HIST_MAXENTRIES%").
[b]Usage:[/b]
Use this set property if you want to change the max entry amount. Expected datatype: Integer
------------------------------------------------------------------------------------
[b]DOWNLOAD[/b]
------------------------------------------------------------------------------------
You can download the history.lss here:
[url]http://www.notes-links.de/cpo/eigenentwicklungen/detail.php?nr=519&kategorie=eigenentwicklungen[/url]
(scroll down to the bottom to see the download the file)
Usage / Example
[b]Quick guide for implementation[/b]
1.) Download the history.lss and import the file into a new script library. Then save the script library, suggested name: “ClassHistory”.
2.) In the appropriate form:
a) add the following line to the ‘Global Declarations’:
Dim g_history As History
b) add the following line to the ‘Global Options’:
Use "ClassHistory"
c) add the following 2 lines to the ‘PostOpen’ event:
Set g_history = New History
Call g_history.PostopenStartObservation(Source, vItemNamesArray)
Please note that you need to have vItemNamesArray as an array of strings or variants
which contains the names of the items which you want to observe an log in the history.
d) Add a field ‘history’. Type: text, allow multiple values, computed when composed,
display separate values with 'New Line'. The 'columns' are separated via tabulator
(chr(9)); so put the field below a table or a text (separated by tabs) with the following
header:
Date | User | Changes