Prevent Agents from sending emails more than once

Have you ever had an agent that ran for years without any issues? Then one day, you simply change the schedule to improve the timing of the emails sent by the agent. Next thing you know, thousands of emails are flying around the system resending emails that have already go out. Some maybe years ago. We have the solution.

First, what was the cause?
If you look at agents closely one of the options is to run against new or modified documents. Every time the agent runs it keeps track of what documents have already been processed. That is the gotcha. When the agent schedule is changed, technically the agent has not be run before so the next time it runs everything will be processed.

Fix
Make two modifications to your agent.

First Step – Set a field on the document for documents already processed.

Formula
Field Processed := true

LotusScript
Doc.Processed = true
Call Doc.Save(true, false)

Second step – Add an if statement to prevent processing of previous messages.

Formula
@if (Processed = true; Skip_Document; Process_Document)

LotusScript
If Doc.Processed = true then
Skip_Document
Else
Process_Document
End if