LOTUSSCRIPT/COM/OLE CLASSES


Examples: GetModifiedDocuments method
This agent gets all modified data documents in the current database since the last time the agent ran. A profile document saves the database end time for each GetModifiedDocuments operation.

Sub Initialize
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Dim dc As NotesDocumentCollection
 Dim doc As NotesDocument
 Dim profile As NotesDocument
 Dim untilTime As NotesDateTime
 Set db = session.CurrentDatabase
 
 ' Check UntilTime in profile document
 Set profile = db.GetProfileDocument("Profile")
 If profile.HasItem("UntilTime") Then
   ' Start processing from UntilTime
   Set untilTime = profile.GetItemValueDateTimeArray("UntilTime")(0)
   Set dc = db.GetModifiedDocuments(untilTime, DBMOD_DOC_DATA)
 Else
   ' First time through get all documents
   Set dc = db.GetModifiedDocuments(, DBMOD_DOC_DATA)
 End If
 
 If dc.Count > 0 Then
   ' Display LastModified and Subject from each document
   Set doc = dc.GetFirstDocument
   While Not(doc Is Nothing)
     Messagebox doc.GetItemValue("Subject")(0),, doc.LastModified
     Set doc = dc.GetNextDocument(doc)
   Wend
 Else
   ' If nothing modified since last time
   If profile.HasItem("UntilTime") Then
     Messagebox "No documents modified",, untilTime.LocalTime
   Else
     Messagebox "No documents modified",, "Beginning"
   End If
 End If
 
 ' Write UntilTime back to profile document
 Call profile.ReplaceItemValue("UntilTime", dc.UntilTime)
 Call profile.Save(True, True, True)
End Sub

See Also