Help with an agent

I have a database for weekly time sheets and I want to be able to create a agent that will send out a reminder to employees who haven’t filled in his/her time sheet for the week.

There are 3 forms; a time sheet form, a employee form, and a week form form.

The week form consists of a week number, a start date, and a end date.

The employee form consists of an employee and a approver.

The week and employee form are used in a picklist to supply those values to the time sheet form.

I want to be able to create a agent that will send out a reminder to the employees who have not submitted a timesheet for the week but I’m not sure how to go about doing it.

Subject: Help with an agent

If you create a view of all the timesheets submitted for the current week, you could loop through them and create an array of all the emps that have submitted one. Then, using a view of all possible employees, loop through each one and test to see if they exist in the submitted array. If not, send the reminder.

Does that help?

Subject: RE: Help with an agent

Thanks Robert.

I got this far. Can anyone help with the array?

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Set db = session.CurrentDatabase



Set view = db.GetView("SAT Last Weeks Time")

Set doc = view.GetFirstDocument	





While Not(doc Is Nothing)

	Messagebox "Employee: " & doc.Employee(0)

	Set doc = view.GetNextDocument(doc)	

Wend	



Set employeeview = db.GetView("Employees")

Set doc2 = employeeview.GetFirstDocument	



While Not(doc2 Is Nothing)

	Messagebox "Employee: " & doc2.Employee(0)

	Set doc2 = employeeview.GetNextDocument(doc2)	

Wend

Subject: RE: Help with an agent

You might be making this more complicated than it needs to be. You could write this in macro language.

emps := @DbColumn(“”; “”; “Employees”; colNo);

emps7Day := @DbColumn(“”; “”; “SAT Last Weeks Time”; anotherColNo);

recipients := @trim(@Replace(emps; emps7day; “”));

@MailSend(“”; “”; recipients; “Please enter your timesheet!”; “Our records show that you are overdue to enter a timesheet.”…)

Of course this depends on having an expensive view that shows only the most recent week’s timesheets. There are ways of doing this that avoid using @Today, which have been discussed here so extensively that I’ll just let you search.

But to do it without such a view, you might find it easiest to use a list in LS.

Dim employeeTrack List As Integer

’ skim down the view of employees…

employeeTrack(doc.GetItemValue(“Name”)(0)) = 0

’ scan the view of timesheets categorized by employee and sorted by most recent first…

use a NotesViewNavigator, read the category heading, then fetch the next document row, look at the date, see whether it’s too old, if it’s recent enough do:

if iselement(employeeTrack(employeename)) then erase employeeTrack(employeename)

finally, loop thru the remaining list elements and send an email to each slacker:

Forall x in employeeTrack

employeeName = listtag(x)

’ send mail to employeename

End Forall

Subject: RE: Help with an agent

If I elected the formula language method would I use a Document selection? I just tried it and got a e-mail for every doc. in the database.

Thanks for the help.

emps := @DbColumn(“”; “”; “Employees”; colNo);

emps7Day := @DbColumn(“”; “”; “SAT Last Weeks Time”; anotherColNo);

recipients := @trim(@Replace(emps; emps7day; “”));

@MailSend(“”; “”; recipients; “Please enter your timesheet!”; “Our records show that you are overdue to enter a timesheet.”…)

Subject: RE: Help with an agent

If you write a formula agent to run on all documents, then yes, it will run once for each document in the database. Notice in the agent properties there’s a Target selection – select None, then the agent will only run once. In that case, there is no document selection.

Alternatively, you could use a document selection to select every Employee document, use the employee name as a key to @DbLookup (instead of @DbColumn) to look up the timesheet documents for just that one employee, see which is the most recent, and send out an email to just that one person if they are late.

Subject: RE: Help with an agent

Thanks I discovered that and it did work but there is no “Target” on a scheduled agent. Any thoughts?

edit: I think I figured it out, create an addition scheduled agent to call it.