This routine prompts the user to describe changes made to the document each time it's saved. The user must provide a description of the change in order to save the document. Otherwise the document is not saved and the user is returned to the document. When the user provides a non-blank description of the change, the history field is updated, including the date, time, person, and description of the change. 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 ElliottUpdated document description.
12/15/2005 5:12:45 PMMark ElliottChanged project start date.
12/16/2005 1:29:23 PMMark ElliottAssigned project to John Doe.
How It Works
A computed field is created on the form to store historical updates. Each time the document is saved in the Lotus Notes user interface, the QuerySave event is triggered and the user is prompted to describe the change (see Figure 13.19). When the user provides a non-blank response, the statement is appended to the history field. Using this approach, a unique description of the change is appended to the history field each time the document is modified and saved.
Figure 13.19. Example of the "document changes" prompt
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, insert the following code into the QuerySave event for the form. Sub Querysave(Source As Notesuidocument, Continue As Variant) Dim w As NotesUIWorkspace Dim s As NotesSession Dim db As NotesDatabase Dim uidoc As NotesUIDocument Dim doc As NotesDocument Dim comment As String Dim statement As String Dim person As NotesName Dim item As NotesItem '---------------------------------------- ' Set object values '---------------------------------------- Set w = New NotesUIWorkspace Set s = New NotesSession Set db = s.CurrentDatabase Set uidoc = w.CurrentDocument Set doc = uidoc.Document Continue = True '---------------------------------------- ' Prompt user to describe change '---------------------------------------- Comment = w.Prompt (PROMPT_OKCANCELEDIT, _ "Event Log", "Briefly describe changes to the document.") If Trim(Comment) = "" Then '---------------------------------------- ' No comment. Display warning. '---------------------------------------- Msgbox "You must provide a comment to save "+_ "the document.", 16, "Warning" Continue = False Else '---------------------------------------- ' Add statement to log '---------------------------------------- Set person = New NotesName(s.UserName) statement = Cstr(Now)+" - "+ person.Common+" - "+ comment Set item = doc.GetFirstItem("HISTORY") Call item.AppendToTextList(statement) End If End Sub |
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?