Subject: RE: Perhaps because [doc.txtTicklerMailSent = “Yes”] removes the document from the view?
Hi Bill,
thanks for the response. It seems it doesn’t work, too
You will find below is the trigger and more information relates to the code and the agent log.
Agent window: First tab:
Shared
Options: Store search in search bar menu
Store highlights in document
Trigger: On schedule
Runtime: More than once a day
Target: All new & modified documents
Schedue:
1 hour (or 5 minutes)
All day
Where the agent runs
Run on: server which this agent and database are currently on.
Below is the updated code for it:
Dim db As NotesDatabase
Dim view As NotesView
Dim vc As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim doc As NotesDocument
Dim SendDoc As NotesDocument
=========================
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim view As NotesView
Dim vc As NotesViewEntryCollection
Dim entry As NotesViewEntry
Dim doc As NotesDocument
Dim SendDoc As NotesDocument
Dim nrtiNotice As NotesRichTextItem
Dim agentlog As NOTESLOG
Dim iDocs As Integer
On Error Goto Quit
iDocs = 0
Set agentlog = New NOTESLOG( “DBTesting” )
Call agentlog.OPENAGENTLOG
Call agentLog.LogAction("Started: " & Time$())
Set db = session.CurrentDatabase
'This is one of the views in my db, you can modify this view according to your db
Set view = db.GetView(“Mike Woo”)
Set vc = View.AllEntries
Set entry = vc.GetFirstEntry()
While Not entry Is Nothing
iDocs = iDocs + 1
Set doc = entry.Document
'ListName is the text field editable on the form.
Call agentLog.LogAction("ListName: " & doc.ListName(0) & “;”)
Print("ListName: " & doc.ListName(0) & “;”)
Set SendDoc = New NotesDocument(db)
Set nrtiNotice = New NotesRichTextItem(SendDoc, “Body”)
Call nrtiNotice.AddNewLine(1)
Call nrtiNotice.AppendText("ListName: " & doc.ListName(0) & “;”)
Call nrtiNotice.AddNewLine(1)
Call nrtiNotice.AppendText("Sent: " & Time$() & “;”)
Call SendDoc.ReplaceItemValue(“Form”, “Memo”)
Call SendDoc.ReplaceItemValue(“SendTo”, “Mike.Woo@mycompany.com”)
Call SendDoc.ReplaceItemValue(“Subject”, "DBTesting: " & Time$())
Call SendDoc.Send(False)
Call doc.ReplaceItemValue(“txtTicklerMailSent”, Time$())
Call doc.Save(True, True)
Set entry = vc.GetNextEntry(entry)
Wend
Call agentLog.LogAction("Ended: " & Str(iDocs))
If Not ( agentLog Is Nothing ) Then
Call agentlog.CLOSE
End If
Exit Sub
Quit:
Msgbox Error & " at line: " & Erl
End Sub
================================
Started running agent ‘DbTesting’ on 06/17/2004 10:02:52 AM
Running on new or modified documents: 19 total
Found 19 document(s) that match search criteria
06/17/2004 10:02:52 AM: Started: 10:02:52 AM
06/17/2004 10:02:52 AM: ListName: XXXXXX;
06/17/2004 10:02:52 AM: ListName: XXXXXX;
06/17/2004 10:02:52 AM: ListName: XXXXX;
06/17/2004 10:02:52 AM: ListName: XXXXX;
06/17/2004 10:02:52 AM: ListName: XXXXX;
06/17/2004 10:02:52 AM: ListName: XXXXX;
06/17/2004 10:02:52 AM: ListName: XXXXX;
06/17/2004 10:02:52 AM: ListName: XXXXX;
06/17/2004 10:02:52 AM: Ended: 8
Ran LotusScript code
Done running agent ‘DbTesting’ on 06/17/2004 10:02:52 AM
where XXXX is name of the document.
I set it for 5 minutes (or 10 minutes, or 1 hour), it didn’t work, too. That’s the result of five minutes scheduling.
I am not sure because of the server or the way I set up the agent or because of the logic in the agent.
Mike Woo.