Background Agent

Hi All

I am creating a database that is for maintenance. Each Job entered into the database will have an expiry date. What I want is the database to automatically email the responsible person one month before the expiry date and then every ten days up until the job has either been completed or has run out!

I would like this to be done automatically meaning the database does not need to be open, is it possible to create an agent to scan the database on a daily basis and perform the action needed.

Regards

Douglas Bell

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