Examples: LogAction method
- This agent script logs actions to a mail memo. It performs a full-text
search on the current database, and logs one action for each document
that matches the full-text search query.
Each time the LogAction method is called, it adds a new line to the Body item of the mail memo. For example, if FTSearch returns a collection of three documents, the body of the mail memo looks like this:
10/25/95 12:26:37 PM Botany Agent starting 10/25/95 12:26:42 PM Document Petals placed in folder. 10/25/95 12:26:44 PM Document Stems placed in folder. 10/25/95 12:26:46 PM Document Leaves placed in folder.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim currentLog As NotesLog
Dim doc As NotesDocument
Dim j As Integer
Set db = session.CurrentDatabase
Set collection = db.FTSearch( "botany", 0 )
Set currentLog = New NotesLog( "Botany Agent" )
Call currentLog.OpenMailLog _
( "Jesse Gora", "Log for Botany Agent" )
For j = 1 To collection.Count
Set doc = collection.GetNthDocument( j )
Call doc.PutInFolder( "Botanist's Delight" )
Call currentLog.LogAction( "Document " & _
doc.Subject( 0 ) & " placed in folder." )
Next
Call currentLog.Close
End Sub
- The call to OpenMailLog in the first script is replaced with the
following:
Call currentLog.OpenNotesLog( "", "agentlog.nsf" )
Each time the LogAction method is called, it creates and saves a new document in AGENTLOG.NSF on the current computer. For example, if FTSearch returns a collection of three documents, one of the new documents created in AGENTLOG.NSF has the following items:
A$PROGNAME "Botany Agent" A$LOGTIME 10/25/95 01:22:24 PM A$USER "Kerry Bowling" A$LOGTYPE "Action" A$ACTION "Document Petals placed in folder."
- The call to OpenMailLog in the first script is replaced with the
following:
Call currentLog.OpenFileLog( "c:\log.txt" )
Each time the LogAction method is called, it adds a new line of text to LOG.TXT. For example, if FTSearch returns a collection of three documents, LOT.TXT looks like this:
Botany Agent: 10/25/95 01:23:33 PM: Document Petals placed in folder. Botany Agent: 10/25/95 01:23:35 PM: Document Stems placed in folder. Botany Agent: 10/25/95 01:23:37 PM: Document Leaves placed in folder.