Help! This agent is not working

This is what its supposed to do this agent:

I have some data in field called “fecha”. Everyday it must go and compared that data in fecha and calculate it has been more than 30 days since date “fecha” has been completed.Then it will generate some emails. Emails are being generate fine, so, Im not pasting that part of agent.

Sub Initialize

Dim s As New notessession

Dim db As NotesDatabase

Dim vista As NotesView

Dim doc As NotesDocument

Dim contador As Integer

Dim estado As NotesItem

Dim docmail As NotesDocument

Dim cuerpo As NotesRichTextItem

Dim manana As New NotesDateTime(Today)

Dim fecha As NotesDateTime

Call manana.AdjustDay( 1 )

Set db = s.CurrentDatabase

Set vista = db.GetView("MejoramientoActivas")

Set doc  = vista.GetFirstDocument

While Not(doc Is Nothing)

	On Error Goto continua

	contador = 0

	Set estado = doc.GetFirstItem("EstadoA")

	Forall v In estado.Values

		If v = "NO" Then

			If doc.Estado(0) <> "Cerrado" Then

				Set fecha = New NotesDateTime(doc.FechaA(contador))

				If manana.TimeDifference ( fecha ) >= 30  Then

					

					Set docmail = db.CreateDocument

Any idea?

Subject: Help! This agent is not working

Carlos,

What error are you getting? Have you turned the debugger on to see which line it is crashing on, or is the agent completing but not picking up any documents??

Mike

Subject: RE: Help! This agent is not working

the error is than its calculating all documents and they arent being filtered by this condition.

—>QUOTE: If manana.TimeDifference(fecha) / (246060) >= 30 Then

tha line its giving me an overflow error. :frowning:

actually i have 280 documents and agent is detecting all, but thats not true…just 20 must be detected by agent

Subject: RE: Help! This agent is not working

Im not sure if error is coming from:

Dim manana As New NotesDateTime(Today)

Dim fecha As NotesDateTime

Call manana.AdjustDay( 1 )

Set db = s.CurrentDatabase

Set vista = db.GetView(“MejoramientoActivas”)

Set doc = vista.GetFirstDocument

While Not(doc Is Nothing)

On Error Goto continua

contador = 0

Set estado = doc.GetFirstItem(“EstadoA”)

Forall v In estado.Values

If v = “NO” Then

If doc.Estado(0) <> “Cerrado” Then

Set fecha = New NotesDateTime(doc.FechaA(contador))

If manana.TimeDifference( fecha )/(86400) >= 30 Then


I repeat idea: Agent need to calculate date on FechaA field (no fecha field) and compare against server date and tell me if document has more than 30 days old

Any idea?

Subject: Help! This agent is not working

Carlos

TimeDifference returns the difference in seconds, so you’ll need to change that value you’re testing for

hth

Dan

Subject: Right: If manana.TimeDifference(fecha) / (24 * 60 * 60) >= 30 Then

Subject: RE: Right: If manana.TimeDifference(fecha) / (24 * 60 * 60) >= 30 Then

the error is than its calculating all documents and they arent being filtered by this condition.

—>QUOTE: If manana.TimeDifference(fecha) / (246060) >= 30 Then

tha line its giving me an overflow error. :frowning:

Subject: Sorry (integer calcs): If manana.TimeDifference(fecha) / 86400 >= 30 Then

Subject: Help! This agent is not working

time difference returns seconds, not days…you would need to get the value then divide by 86400 to get the number of days

thanks

barry