AliciaVee
asked on
Send Reminder Agent
Experts,
II am looking for a simple lotusscript (or formula) that will send an email to "more than one person" that will be listed in a "Task Owner" field. Basically, the agent should do the following:
1. find documnets where the status is not equal to completed
2. send reminder on a weekly basis, once the DueDate is overdue, but monthly otherwise
3. include the TaskName in the reminder
4. Include the database name (instead of the server name -- so using the principle property
I tried to use some old LS agents I had, but nothing seems to work -- probably because the other agents were overkill.
Does someone have something similar -- I can probably tweak to make it work for me.
Thanks in advance.
II am looking for a simple lotusscript (or formula) that will send an email to "more than one person" that will be listed in a "Task Owner" field. Basically, the agent should do the following:
1. find documnets where the status is not equal to completed
2. send reminder on a weekly basis, once the DueDate is overdue, but monthly otherwise
3. include the TaskName in the reminder
4. Include the database name (instead of the server name -- so using the principle property
I tried to use some old LS agents I had, but nothing seems to work -- probably because the other agents were overkill.
Does someone have something similar -- I can probably tweak to make it work for me.
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oops-- forgot to show the agent/tweaks. I simply changed the a few of the constants (Complete from Completed; People in the RecipeintsFieldName and changed the Subject)
Const STATUS_FIELD_NAME = "Status"
Const COMPLETED_STATUS_NAME = "Complete"
Const DUE_DATE_FIELD_NAME = "DueDate"
Const RECIPIENTS_FIELD_NAME = "People"
Const MAIL_SUBJECT = "Objective Task is not 'Complete'"
Const TASK_NAME_FIELD = "Subject"
Const STATUS_FIELD_NAME = "Status"
Const COMPLETED_STATUS_NAME = "Complete"
Const DUE_DATE_FIELD_NAME = "DueDate"
Const RECIPIENTS_FIELD_NAME = "People"
Const MAIL_SUBJECT = "Objective Task is not 'Complete'"
Const TASK_NAME_FIELD = "Subject"
Sub Initialize()
Const STATUS_FIELD_NAME = "Status"
Const COMPLETED_STATUS_NAME = "Complete"
Const DUE_DATE_FIELD_NAME = "DueDate"
Const RECIPIENTS_FIELD_NAME = "People"
Const MAIL_SUBJECT = "Objective Task is not 'Complete'"
Const TASK_NAME_FIELD = "Subject"
Dim s As New NotesSession
Dim db As NotesDatabase
Dim c As NotesDocumentCollection
Dim cur As NotesDocument, mail As NotesDocument
Dim body As NotesRichTextItem
Dim dueDate As NotesDateTime, todaysDate As New NotesDateTime(Today)
Dim found As Boolean
Set db = s.CurrentDatabase
Set c = db.UnprocessedDocuments
If c Is Nothing Then Exit Sub
If c.Count = 0 Then Exit Sub
Set cur = c.GetFirstDocument
Do Until cur Is Nothing
If cur.GetItemValue(STATUS_FIELD_NAME)(0) <> COMPLETED_STATUS_NAME Then
Set dueDate = New NotesDateTime(cur.GetItemValue(DUE_DATE_FIELD_NAME)(0))
If todaysDate.TimeDifference(dueDate) >= 0 Then 'if due date is passed or it's today
'here we create temporary document for mailing (without saving it)
Set mail = New NotesDocument(db)
Call mail.ReplaceItemValue("SendTo", cur.GetItemValue(RECIPIENTS_FIELD_NAME))
Call mail.ReplaceItemValue("Subject", cur.GetItemValue( TASK_NAME_FIELD )(0) + MAIL_SUBJECT)
Set body = New NotesRichTextItem(mail, "Body")
Call body.AppendText(cur.GetItemValue( TASK_NAME_FIELD )(0))
Call body.Addnewline(2)
Call body.AppendText("Click on this link to open the document:")
Call body.AddTab(1)
Call body.AppendDocLink(mail, "Document link")
Call mail.Send(False)
End If
End If
Set cur = c.GetNextDocument(cur)
Loop
End Sub
ASKER
mbonaci -- was off on a business trip -- am back and will look at this in a day or so. Thanks!!
ASKER
This agent looks great! (short and simple to understand).
I have a computed field called "People" that grabs the task owners and uses the following code:
@Name([Abbreviate];ObjTask
Since I want two different forms, searched for due dates, I put the People computed field on each form (it should grab multiple names if more than one person is assigned to the task? Please confirm)
I also have a similar computed Subject field that grabs the task name.
I've made a couple of tweaks, as shown, and when I tried to run it, I get an error that states:
"Notes Error: No names found to send mail to"
this is also the data shown after "run" of the agent:
Started running agent 'ReminderWeekly' on 02/06/2011 11:54:18 AM
Running on all documents in database: 10 total
Found 10 document(s) that match search criteria
Ran LotusScript code
Done running agent 'ReminderWeekly' on 02/06/2011 11:54:22 AM
I have made 1 document late -- assigned to me, so I should get a reminder, but yet the info above says the agent found 10 doucments -- does that mean 10 documents were searched to identify if the reminder should be sent, or will all 10 get this reminder?
I'll hold off doing anymore testing until I hear from you -- since I don't want others on the tasks getting the test reminders (thanks!)