Hi,
I am trying to write an Agent to run on a specific view (which identifies documents of a certain age). I need it to change a field (status) from Pending to Open and also send an email to the named person on the document who created it (also containd in a field named CoOrdinator).
I setup an Agent as follows but it doesn't seem to work, any suggestions would be most gratefully received as i'm hitting my head against a brick wall right now!
Which doc should agent act on = All docs in view
(Options)
blank
(Declarations)
Dim session As notessession
Dim db As NotesDatabase
Dim doc As notesdocument
(Initialize)
Sub Initialize
Set session = New notessession
Set db = session.CurrentDatabase
Set view = db.GetView("testlou")
Set doc = view.GetFirstDocument
If Not (doc Is Nothing) Then
Call TestEmail
End If
End Sub
(TestEmail)
Sub TestEmail
Dim DocMail As notesdocument
Dim RtBody As notesrichtextitem
Dim mydb As notesdatabase
Set mydb = sess.currentdatabase
DocMail.Status ="Open"
'email
Set docMail=mydb.CreateDocument
Set RTBody=docMail.CreateRichTextItem("Body")
docMail.subject="CSST Database Request - " & DocA.RefNo(0) & " "& DocA.CaseType(0) & " - "& DocA.ClientLists(0) &" - Request Moved OUT of Pending"
docMail.SendTo= docA.CoOrdinator
'email content
Call RtBody.AppendText( "Dear " & docA.CoOrdinator (0))
Call RtBody.AddNewLine( 2 )
Call RtBody.AppendText( DocA.RefNo(0) & " \" & docA.Reason(0) & "\" & " "&"Submitted on the " & DocA.SubmitTime(0))
Call RtBody.AddNewLine( 2 )
Call RtBody.AppendText( "The above request has been moved out of Pending as it has been there for over 21 days, please action as soon as possible. " )
Call RtBody.AddNewLine( 2 )
Call RtBody.AppendText("To view and action the request please access the link below." _
& " click on the following document link -----> ")
Call RtBody.Appenddoclink(DocA, "Link to request - " &DocA.RefNo(0))
Call RtBody.AddNewLine( 2 )
docMail.send(False)
End Sub
Many Thanks,
Louise

Scheduled Agent to Change a Field &... (Louise Owen 3.Feb.10)
. . 