web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Trying to get TaskScheduler to work

(0) ShareShare
ReportReport
Posted on by 33

Dear Business Central / AL developer experts,

I am trying to get the TaskScheduler to work. I can schedule a task, it is visible in the "Scheduled Tasks" table. At the scheduled time, a row in the "Session Events" table appears. But the task does not do it's usual work. What can be the reason for this?

I wrote a test CodeUnit, if I run it by hand it writes a message to a custom log table. If I schedule it, the message does not get written.

Please see the code below.
Also added: a zip of the AL test project (with the MS apps removed to make it uploadable).

===========================

codeunit 60001 TaskSchedulerTest
{
    //This is the Task to perform.
    trigger OnRun()
    var
        Log: Record MessageLog;
    begin
        Log.Log(3, 'The test CodeUnit 60001 has run!');
    end;

    //This should schedule the Task, a chosen number of minutes after NOW.
    procedure ScheduleMe()
    var
        MinutesAfterNow: Integer;
        TargetCompany: Text;
        NotBefore: DateTime;
        TaskGuid: Guid;
    begin
        //Configure the scheduling
        MinutesAfterNow := 20;
        TargetCompany := 'Entocare CV';  //Change it

        //Schedule this CodeUnit
        NotBefore := CreateDateTime(Today(), Time())   MinutesAfterNow * 60 * 1000;
        if not TaskScheduler.CanCreateTask() then
            Error('CanCreateTask is false.');
        TaskGuid := TaskScheduler.CreateTask(70001, 0, true, TargetCompany, NotBefore);
        Message('Scheduled: '   TaskGuid);
    end;
}

TaskSchedulerTest.zip

I have the same question (0)
  • Suggested answer
    Andy Sather Profile Picture
    Microsoft Employee on at

    Hello  - We currently do not have Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    community.dynamics.com/.../758

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

  • Wolter Kaper Profile Picture
    33 on at

    Hello,

    The second one of your three links points to the Dynamics 365 Business Central forum. It looks exactly like the one you are telling me is not right. I'll use the other two, thanks.

    A year ago there were a lot of dev questions here, and answers too. Mm... Okay.

  • Andy Sather Profile Picture
    Microsoft Employee on at

    Hello Wolter.  You can still post Dev questions on here on this forum.  I am just saying we do not have Microsoft Employees in Development that monitor this forum.  The support team that monitors this forum are application engineers.

    The other 2 forums are more Dev related and could get you the answers you are looking for faster.

  • Wolter Kaper Profile Picture
    33 on at

    Andy,

    Okay, thanks, I'll do that...!

    It's perhaps best if you delete my post in this forum otherwise people can accuse me of cross-posting.

    With best regards, Wolter

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,072 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,129 Super User 2026 Season 1

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 650 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans