The 'User Activity' log in the 'database preferences' records when a user has read/written to a database. However, it doesn't list what documents the user has been opening/writing. This code records what documents a user has been reading/writing even if they have only 'Read' access in the ACL.
To implement on a database:
1. Create a Form in the database. ('Log' in the code)
2. In the form create two fields, one is the log data field, which should be
rich text (AccessLog in the code). The
other a date field. (LogDate in the Code)
3. Goto properties. In 'Golden Key' section, select 'Available to Public
4. Create a view in the database. ('LogView' in the code)
5. Selection formula is by the form you created (e.g. SELECT Form = "Log")
6. Add one column and set the data as @Created.
7. Cut and paste the code below into the form you want to record user activity
(in the terminate event of the form)
8. Update the Constants in the code to the Log form and view name.
9. Change the 'TitleField' constant to the identification field in the form
(i.e. when you read the log, it identifies the document)
'Version : 1.02
'Function : Record all reads by any user of the database in a daily log (1
log per day)
'Author : Christopher Williamson/Development
'Date : 21/06/2000
'Get the user & form details
'Check if today's log exists
'If it does update it
'Else Create log and write details
'Save the doc
'Change these vars to reqs
'The title field used to identify document in the log
Const TitleField = "Doc_Title_1"
'The view name for the log documents
Const LogViewName = "By Log"
'The date field of the log
Const LogDateField = "LogDate"
'The details field in the log (must be multivalue)
Const LogDetailsField = "AccessLog"
'The form name in the log
Const LogFormName = "Log"
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim udoc As NotesDocument
Dim doc As NotesDocument
Dim uidoc As NotesUIDocument
Dim newdoc As NotesDocument
Dim view As NotesView
Dim LogExists As Integer
'Lazy Error handler - this is only required if a user creates a doc then
On Error Resume Next
'Get the current doc
Set uidoc = workspace.currentdocument
Set udoc = uidoc.Document
'Get the reader name and current date & time
user = Evaluate("@Name([Abbreviate]; @UserName)")
dateread = Evaluate("@Now")
readstring = user(0)
readstringdate = dateread(0)
'The string that is written to the log.
displayall = readstring & " : " & readstringdate & " : " &
udoc.GetFirstItem("Form").text & " : " & udoc.GetFirstItem(TitleField).text &
'get the current log docs from the 'Log' view
Set view = Session.CurrentDatabase.GetView(LogViewName)
'get the last doc (reuse the doc var as it wont be used again)
Set doc = view.GetLastDocument
'loop thro logs and look for a log created today
Do While Not doc Is Nothing And Not LogExists
Set temp = doc.GetFirstItem(LogDateField)
If temp.text = Format(Date$,"dd/mm/yyyy") Then
LogExists = -1
Set doc = View.GetPrevDocument(doc)
'if doc already exists then update the field
If Not doc Is Nothing Then
Set item = doc.GetFirstItem(LogDetailsField)
'create the doc
Set newdoc = session.currentdatabase.Createdocument
newdoc.form = LogFormName
'give all users access to write this log (although they don't have a
clue >:) )
Dim PublicAccess As New NotesItem(newdoc, "$PublicAccess","1")
'write the text to doc
Dim item2 As New NotesItem(newdoc, LogDetailsField, displayall)
'write the date to doc
Dim item3 As New NotesItem(newdoc,LogDateField, Format(Date$,
MEMBER FEEDBACK TO THIS TIP
Can the code be put into Memo form to record e-mail activity, or does a form exist for All Documents so that all activity on a mail file can be recorded?