run a job monthly

jobs can be run using job queues. in the job queue entry card you can set a codeunit or a report to run periodically. periods can: minutes to days. it is also possible to run a job once a week.

not possible: run a job monthly.

here are some solutions.

the simple solution:
goto page “job queue entry card” and set “no. of minutes between runs” to a value like 43200 (= 60 * 24 * 30). that is the minute value for an average month. the exact average value is 60 * 24 * 365,25 / 12 = 43830 min.

recurr-job

advanced solution:
edit cu 448 and change fct. CalcNextRunTimeForRecurringJob according to your special needs. There change the calc. formula for NewRunDateTime.

cu-448-nextjobrun

to run a job monthly set “No. of Minutes between Runs” to 0.
create new global var. Monthly: Boolean.

change fct. CalcRunTimeForRecurringJob:

IF Found THEN
NewRunDateTime := CREATEDATETIME(DT2DATE(StartingDateTime) + NoOfDays,NewRunTime);

IF Monthly THEN BEGIN
LastOfMonth := CALCDATE (‘CM’, DT2DATE(StartingDateTime));
NewRunDateTime := CREATEDATETIME(LastOfMonth, NewRunTime);
END;

new fct. RunMonthly(monthlyPar: Boolean)
Monthly := monthlyPar;

Advertisements

2 thoughts on “run a job monthly

  1. Rajesh says:

    Hi Jonathan,

    I have tried advance solution. i have created two fields in job queue entry. Periodically (Boolean) and period (calcformula) so that i can run based on periods (15D, 1M). but next run date is doubled up (15D +15D).

    for your advance solution, where this following function we call.
    new fct. RunMonthly(monthlyPar: Boolean)
    Monthly := monthlyPar;

    Thanks for your post.

    Regards,

    Rajesh

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s