@Return not working

Hi,

I have the following formula agent which has been running for ages and now it has decided to send Emails to all users regardless of the expiry date. It would appear that the @Return on the HSTDateDif is no longer working - any ideas?

REM {This agent is ran daily at 1am};

REM {This agent is used to send Emails to the named person and the DSRs};

REM {When an Employee Training Record is a month from expiry};

REM {The EmailSent field is set to Yes so that only one Reminder is Sent};

@If(EmailSent=“Yes”;@Return(“”);“”);

@If(HST_No_End_Date=“”;“”;@Return(“”));

@If(HST_Expiry_Date!=“”;“”;@Return(“”));

HSTdatedif:=@Integer((@Now - HST_Expiry_Date) / (60 * 60 * 24));

@If(HSTdatedif!=-30;@Return(“”);“”);

emailsubject:=(“Message from HASIT: Personal Training Record will expire in 30 days”);

EmailText1:=“Personal Training for “+HST_Name+” of type “+HST_Training_Type+” will expire in 30 days”;

EmailText2:=“Follow the link at the end of this message to go to the relevant record in the HASIT Database”;

Lookup:=@DbLookup(“”; “”;“EmailText”;“Training”;“EmailText”);

LookupEmailText:=@If(@IsError(Lookup);“”;Lookup);

@MailSend(EmailList;“”;“”;emailsubject;“”;EmailText1+@NewLine+@NewLine+LookupEmailText+@NewLine+@NewLine+EmailText2+@NewLine;[IncludeDoclink]);

FIELD EmailSent:=EmailSent;

@SetField(“EmailSent”;“Yes”);

SELECT @All

Thanks

Subject: @Return not working

Two random ideas:1) If you can test the code try putting an @Prompt in where the “” e.g. @Return(@Prompt etc then you can see if it got to that part;

  1. Bit of a random one, try declaring the date fields and the EmailSent field at the very top of the code with:

FIELD EmailSent:=EmailSent etc

  1. Have you checked the fields are set correctly using the document properties?

Subject: @Return not working - solved

Hi, Thanks for your suggestionsRealised when checking the field settings that the HST_Expiry_Date is now set as a text field so the datedif is getting an error Have managed to fix it by checking for the Error and converting TextToTime

Thanks again

Subject: RE: @Return not working - solved

Please don’t store date fields as text. What do you think is going to happen if some users have different date formatting preferences than other users? You see “09/08/2008” in the field – is that August 9 or September 8? It depends who saved the document.