Select formula not working in scheduled agent

Hi all,

I have a scheduled agent that runs on all documents in the database but selects two forms in its code. The agent, for some reason for the past two weeks has been running and causing an overwhelming quantity of emails to be sent to two individuals. It is supposed to run on docs that have the form name “frmPO” or “frmTallardPO” & field “InvoiceOnDelivery” = “Yes” & field “CustomerDeliveryDate” !=NULL & field “Invoiced” != “Yes”.

A lot of the documents in the database have the field called “InvoiceOnDelivery” equal to “No”, and the agent still selects those documents and runs and sends the same email notifying the end user to “please produce an invoice for Job No.” .

Is there a reason why the agent is doing this? When I run the agent (a non-scheduled version) myslef it does exactly what it is supposed to do.

Here is the code:

ds:=@If(@IsAvailable(DateSubmitted);@Date(DateSubmitted);@Date(@Today));

dd:=CustomerDeliveryDate;

today:=@Date(@Today);

SELECT Form =(“frmPO”:“frmTallardPO”) & InvoiceOnDelivery = “Yes” & CustomerDeliveryDate !=NULL & Invoiced != “Yes”;

SendTo:=@If(@Contains(Division ; “Network”) ; “netbilling@corp.com” : "dlebrun@ corp.com " ; "telbilling@ corp.com " : "dlebrun@ corp.com ");

CopyTo:=“”;

BlindCopyTo:=“”;

Link:=“http://corp1/po/fsmain!Open&Frame=fMid&Src=/ponumber/” + PONumber + “!Open&Login”;

Subject:=" ALERT: " + PONumber + " (Please produce an invoice for Job No " + GPJobNumber + ") as the order has been delivered to " + Customer;

@MailSend(SendTo;CopyTo;BlindCopyTo;Subject;“”;@NewLine:"Follow the link to view/approve: ":Link)

Thanks,

Dan

Subject: Select formula not working in scheduled agent

With the exception of SELECT @All, the SELECT statement has to be in the first line of a formula agent. Look it up, it’s in the documentation.