跟踪谁正在读哪个文档

2016-04-02  本文已影响18人  IT小C

Description:  There have been times where you what to see who has been reading what documents in a database. This helps track if the right audiance is looking at your documents and what documents are being used and which ones are not beeing looked at.

There are 2 methods to accomplish this:
In the Terminate event of the database document, put the following script in. This script will do 2 things when a document is closed:

a) it will mail a notice to a log database that you have to create. This database you can create from a blank template and create one form called a "memo" with 3 fields: From, Subject & PostedDate. And

b) update a "who_read" field you add to the form.

Obviously you do not need both features, just 1 of them: either create a database log of who reads what documents or a reader field.

Code:

Dim session As New NotesSession 
Dim workspace As New NotesUIWorkspace 
Dim maildb As NotesDatabase
Dim maildoc As NotesDocument
Dim uidoc As NotesUIDocument 
Dim doc As NotesDocument
Dim item As NotesItem

Set uidoc = workspace.currentdocument
Set doc = uidoc.Document 

' Get the reader name and current date & time 
user = Evaluate("@Name([Abbreviate]; @UserName)")
dateread = Evaluate("@Now")
readstring = user(0)
readstringdate = dateread(0)
displayall = readstring & " : " & readstringdate

' Append the current reader and date to the WhoRead field 
Set item = doc.GetFirstItem( "WhoRead" ) 
Call item.AppendToTextList(displayall) 
Call doc.Save(False,True)

' Mail the data to the log database for easy searching 
mailsubject = uidoc.FieldGetText("Subject") 
Set maildb = session.currentdatabase
Set maildoc = New NotesDocument ( maildb )
maildoc.Form = "Memo"
maildoc.SendTo = "name of mail-in database"
maildoc.Subject = "Read America Wire Dcoument titled: " + mailsubject
Call maildoc.Send( False ) 
上一篇 下一篇

猜你喜欢

热点阅读