Record User Activity On Access To Documents

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.

View member feedback to this tip.

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
Access Users'
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)
10. Launch.
Sub Terminate
'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
'Method :
'Initialise Variables
'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
'End

'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
cancels
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 &
Chr$(13)

'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
Else
Set doc = View.GetPrevDocument(doc)
End If
Loop

'if doc already exists then update the field
If Not doc Is Nothing Then
Set item = doc.GetFirstItem(LogDetailsField)
Call item.AppendToTextList(displayall)
Call doc.Save(False,False)
Else
'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$,
"dd/mm/yyyy"))
Call newdoc.Save(False,False)
End If
End Sub


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?

—Andrew W.

This was first published in November 2000

Dig deeper on Lotus Notes Domino Administration Tools

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close