Navision Financials Cron Support

Components
table 50165 ( crons ) : Crons configuration
codeunit 50058 ( crons ) : Algorithmic
form 50337 ( crons ) : Configuration form.

Crons table schem:

Column Spanish Tipe Size Comment
code codigo integer   Autoincremental code
minute minuto text 2 0..59
hour hora text 2 0..23
month_day dia_mes text 2 1..31
month mes text 2 1..12
week_day dia_semana text 2 0..7 ( 0 = sunday )
id_funtion id_funcion integer   function identifier to launch with cron
function funcion text 50 Function name
description descripcion text 250 Free description
last_date ultima_fecha date Last launch date
last_hour ultima_hora time Last launch time
executed ejecutado boolean Cron executed in last loop
user usuario code 10 User cron owner
group grupo code 20 Group cron owner
enabled habilitado boolean Cron is enabled or not

Cron configuration example

Enabled User Group minute hour month_day month week_day id function description
true cnn 10 * * * * 1 testCron()  
true cnn 20 * * * * 1 testCron()  
false all_users 0 0 * * 0 2 testDbSpace()  

first cron is anabled just for user cnn and it will launch testCron() function every minute 10 every hour every day.

second cron is anabled just for user cnn and it will launch testCron() function every minute 20 every hour every day.
thirth cron is disabled and it's configured for allusers group and it would run every sunday at 00:00

Example Codeunit Crons: ...

function testCron() // id = 1
   begin
      someCodeForTestingCron();
   end

function testDbSapace() // id = 2
   begin
      someCodeForTestingDbSpace();
   end;

Note you must write cron functions in crones codeunit and update launchCron() function so engine can handle those new functions.


Using:
If you want a cron to be launched at diferent times, you must write several lines !!

In main menu, write a timer with timer interval property = 60000 with crons.launchCrons(); at ontimer trigger.
That's all !!