%REM Library AgentSupport Created Jan 6, 2010 by Stephan H Wissel/Singapore/IBM Description:Common Classes that make writing agents easier %END REM Option Public Option Declare %REM Class AgentSupport Description: For agents to walk through documents %END REM Public Class AgentSupport Public s As NotesSession Public db As NotesDatabase Public agent As NotesAgent Private doc As NotesDocument Private nextDoc As NotesDocument Private docToProcessStarted As Boolean %REM Sub New Description: Comments for Sub %END REM Sub New Set s = New NotesSession Set db = s.Currentdatabase Set agent = s.Currentagent End Sub %REM Function getCollection Description: all the unprocessed documents %END REM Public Function getCollection As NotesDocumentCollection Set getCollection = db.Unprocesseddocuments End Function %REM Function getDoc Description: for submitted documents %END REM Public Function getDoc As NotesDocument Set getDoc = s.Documentcontext End Function %REM Sub Updateprocesseddoc Description: Update the processed doc %END REM Public Sub Updateprocesseddoc(doc As NotesDocument) Call me.s.Updateprocesseddoc(doc) End Sub %REM Function docToProcess Description: Returns a document to be processed %END REM Public Function docToProcess As NotesDocument If me.getCollection() Is Nothing Then If docToProcessStarted = True Then Set docToProcess = Nothing Else 'We return that one document to process Set docToProcess = me.getDoc() End If docToProcessStarted = true Exit function End If 'All documents selected If docToProcessStarted Then Set docToProcess = nextDoc Set nextDoc = me.getCollection().Getnextdocument(nextDoc) Else Set doc = me.getCollection().Getfirstdocument() Set nextDoc = me.getCollection().Getnextdocument(doc) Set docToProcess = doc docToProcessStarted = true End If End Function End Class