Subject: Background Agent
Yes, it’s certainly possible.I have created a few of these agents in my time…just need a scheduled agent, maybe schedule at night time in case it slowed it down…
You can use the @Adjust formula to determine if you need to send.
Here’s some code of an example I made recently:
This sends an email 7 days before someone goes on holiday:
FIELD Days_Holi := Days_Holi;
FIELD Days_Flexi := Days_Flexi;
FIELD Man_Group:=Man_Group;
FIELD Stamp:=Stamp;
FIELD gtAuthor := @ProperCase((@Name([CN]; gtAuthor)));
Length := (Days_Holi + Days_Flexi);
@If(Length <= 2;“”;
@Do(
FIELD Start_Date := Start_Date;
tLength:= @Text(Length);
tStart := @Text (Start_Date);
TempTextStartDate:=@Text(Start_Date);
SendDate := @If(Start_Date!=“”; @Adjust(Start_Date;0;0;-7;0;0;0);“”);
DateNow := @Date(@Today);
SendNoticeNow := @If(DateNow = SendDate;“Yes”;“No”);
@If(SendNoticeNow="Yes" & Stamp="";
@Do(
DB := "";
View := "gtLkupRecs2";
Key := "HolRemTxt1";
ColumnNumber := 2;
HolRemTxt1 := @DbLookup("Notes":"NoCache" ; DB; View; Key;ColumnNumber);
DB2 := "";
View2 := "gtLkupRecs2";
Key2 := "HolRemSub";
Key3 := "HolRemTxt2";
Key4:= "HolRemTxt0";
ColumnNumber2 := 2;
HolRemSub := @DbLookup("Notes":"NoCache" ; DB2; View2; Key2; ColumnNumber2);
HolRemTxt2 := @DbLookup("Notes":"NoCache" ; DB; View; Key3;ColumnNumber);
HolRemTxt0 := @DbLookup(“Notes”:“NoCache” ; DB; View; Key4;ColumnNumber);
FIELD Bus_Group := Bus_Group;
FIELD Year:=Year;
FIELD BGroup_look:=BGroup_look;
tYear:=@Year(@Date(@Today));
TexttYear:=@Text(tYear);
YearBus_Group:=Bus_Group:" ":TexttYear;
TrimYearBus_Group:=@Trim(YearBus_Group);
@If(BGroup_look=“”;“”;
mailgroup :=@Unique(@DbLookup(“Notes”:“NoCache” ; “”; “HolidayAvaliableFlat”; BGroup_look;“Emp_Name_2”)));
@SetField(“Stamp”;"Reminder email sent by " + @Name([CN];@ServerName) + " on " + @Text(@Date(@Today)) + “.”) ;
@MailSend(mailgroup;Man_Group;“Generic Notes Developer/Country-Continent/CompanyName/Domain”;gtAuthor + " has a holiday commencing on " + tStart + " for " + tLength + " days…“;”";HolRemTxt0 + @NewLine + @NewLine + HolRemTxt1 +@NewLine + @NewLine + HolRemTxt2 + “.”)
;“”); “”)));
SELECT @All