This routine illustrates how to automatically append an event stamp to the document field every time the document is saved using the Notes client user interface (also known as the "front-end" interface). Each time the document is saved, the date, time, and user name are added to the history field. It's important to recognize that changes are not logged if the document is modified through "back-end" LotusScript programming. The following illustrates event stamps that could be appended to the field each time the document is saved.
12/10/2005 8:42:10 AMMark ElliottDocument changed.
12/15/2005 5:12:45 PMMark ElliottDocument changed.
12/16/2005 1:29:23 PMMark ElliottDocument changed.
How It Works
There are a variety of ways to automatically log or track changes to a document. One method often used to track changes is to log a comment each time the document is saved. This is achieved by creating a computed field on the form to store the history information and adding code in the QuerySave event to log the update. Using this approach, a statement is appended to the field each time the document is saved.
Implementation
To implement this solution, complete the following steps.
Step 1. |
Create a new field on the form. In the properties dialog, set the field name to History and field type to Computed and select Allow multiple values. On tab 2, set the Display separate values field to New Line and then close the properties dialog. If you elect to use an alternate field name, be sure to adjust the following instruction and statements. |
Step 2. |
In the Programmer's pane, set the "value" formula for this field to History. |
Step 3. |
To complete the setup, add the following code to the QuerySave event for the form. Sub Querysave(Source As Notesuidocument, Continue As Variant) Dim w As New NotesUIWorkspace Dim s As New NotesSession Dim db As NotesDatabase Dim uidoc As NotesUIDocument Dim doc As NotesDocument Dim statement As String Dim person As NotesName Dim item As NotesItem '---------------------------------------- ' Set object values '---------------------------------------- Set s = New NotesSession Set db = s.CurrentDatabase Set uidoc = w.CurrentDocument Set doc = uidoc.Document '---------------------------------------- ' Define statement to be added to log '---------------------------------------- Set person = New NotesName(s.UserName) statement = Cstr(Now) + " - " + person.Common +_ " - " + "Document changed." '---------------------------------------- ' Append statement to log '---------------------------------------- Set item = doc.GetFirstItem("HISTORY") Call item.AppendToTextList(statement) End Sub |
Prompt the User to Describe Document Changes and Update the History Log |
An Introduction to the Lotus Domino Tool Suite
Getting Started with Designer
Navigating the Domino Designer Workspace
Domino Design Elements
An Introduction to Formula Language
An Introduction to LotusScript
Fundamentals of a Notes Application
Calendar Applications
Collaborative Applications
Reference Library Applications
Workflow Applications
Web Applications
Design Enhancements Using LotusScript
Design Enhancements Using Formula Language
View Enhancements
Sample Agents
Miscellaneous Enhancements and Tips for Domino Databases
Data Management
Security
Application Deployment and Maintenance
Troubleshooting
Appendix A. Online Project Files and Sample Applications
Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?