The method UpdateProcessedDoc in NotesSession class

The method UpdateProcessedDoc in NotesSession class can be used to mark a document as already processed by an agent in order to prevent it from being processed again by the same agent or may not be used on a specific document in the event of some condition for which you wants it to be processed again the next time the agent will run.
The agent is scheduled, usually it processes documents in a NotesDocumentCollection returned by UnprocessedDocuments, or UnprocessedFTSearchRange UnprocessedFTSearch method.

Here is an example:

Option Public
Option Declare

Sub Initialize
	
	Dim s As New NotesSession
	Dim db As NotesDatabase
	Dim dc As NotesDocumentCollection
	Dim doc As NotesDocument
	Dim saved As Boolean
	
	Set db = s.Currentdatabase

	' you can use Unprocesseddocuments, UnprocessedFTSearch or UnprocessedFTSearchRange
	Set dc = db.Unprocesseddocuments
	
	Set doc = dc.Getfirstdocument()
	While Not(doc Is nothing)
		
		call ProcessDocument(doc)
		
		saved = doc.Save(false, false, false)
		
		' the condition is if the document is saved but you use other conditions
		If saved Then		
			' well done!	
			Call s.UpdateProcessedDoc(doc)
		Else
			' I'll process this document the next time
		End If
		
		Set doc = dc.Getnextdocument(doc)
	Wend

End Sub

Sub ProcessDocument(doc As NotesDocument)
	
	' some stuff here
	Call doc.Replaceitemvalue("SomeField", "SomeValue")
	
End Sub

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.