DateTime dialogues, Business Central is slowly catching up!

No reason to assume that you’ll have to do everything yourself. The system library is getting more and more useful functions, check this out:

https://youtu.be/-xbQ0IYxuPc

In this video, Erik explores the Date-Time Dialog — one of the common dialog pages that Microsoft has been adding to the System Application in Business Central. He walks through how to use it, what options are available, and why the growth of the System Application matters for AL developers.

The Lack of Common Dialogs in NAV and BC

Most application platforms ship with a long list of commonly used dialogs — think of Windows with its color picker, file open/save dialogs, and specialized data entry controls like date and time pickers. These are often referred to as common dialogs.

In the world of NAV and Business Central, this has never really been part of the core product. Sure, there have been pages here and there that could function as generic dialogs — for example, the “Select Field” dialog that shipped with the configuration package functionality — but these were tied to specific contexts. Even though they might appear generic, you couldn’t depend on them staying generic, since they were built for a particular purpose. Using them for your own scenarios was sometimes unwise because they could change without notice.

The System Application Changes Everything

With the rapid expansion of the System Application, things are changing. Anything that goes into the System Application is not intended for a specific business purpose and cannot have any relationship with Base Application objects. This means Microsoft is starting to add genuinely reusable, generic features — including common dialogs.

The one Erik explores in this video is the Date-Time Dialog page.

Using the Date-Time Dialog

Erik starts with a simple page extension on the Customer List to demonstrate the dialog. Here’s the final working code:

pageextension 50100 CustomerListExt extends "Customer List"
{
    trigger OnOpenPage();
    var
        DateTimeDialog: Page "Date-Time Dialog";
    begin
        //DateTimeDialog.UseDateOnly();
        DateTimeDialog.Caption('What date do you go on vacation?');
        DateTimeDialog.SetDateTime(CurrentDateTime());
        if DateTimeDialog.RunModal() = Action::OK then begin
            message('You selected %1', DateTimeDialog.GetDateTime());
        end;
    end;
}

What the Dialog Offers

By pressing F12 to peek at the dialog’s interface, Erik identifies the available methods:

  • SetDateTime() — Sets the initial date and time value displayed in the dialog
  • GetDateTime() — Retrieves the date and time the user selected
  • UseDateOnly() — Switches the dialog to show only a date picker, omitting the time portion
  • Caption() — Sets a custom caption on the dialog window

Running the Dialog

The pattern is straightforward:

  1. Declare a variable of type Page "Date-Time Dialog"
  2. Optionally configure it with SetDateTime(), UseDateOnly(), or Caption()
  3. Call RunModal() and check if the user clicked OK
  4. Retrieve the selected value with GetDateTime()

When running the dialog without any configuration, it shows a default “Edit Date-Time Dialog” caption with an embedded date picker. The time portion, however, doesn’t have a dedicated time picker control — you have to type time values manually, which can feel a bit clunky.

Setting the caption to something meaningful like “What date do you go on vacation?” makes it much more user-friendly, though Erik notes it would be nice if the word “Edit” could be removed from the dialog title.

Date Only Mode

If you uncomment the UseDateOnly() call, the dialog drops the time component entirely and just presents a date picker. This is useful when you’re only asking the user for a date.

The Power of Open Source

One important thing to remember is that the System Application is open source. If you have ideas to make the Date-Time Dialog better — say, adding a proper time picker control — you can download the source code, make your changes, and submit a pull request to Microsoft. If your code meets their standards, it gets merged in, and you’ve contributed your own small footprint to Business Central.

Summary

The Date-Time Dialog is a simple but welcome addition to Business Central’s System Application. While it’s still fairly basic — lacking a visual time picker and carrying a slightly awkward default caption — it provides a clean, supported way to prompt users for date and time input. As Microsoft continues to expand the System Application with more common dialogs and utilities, AL developers get building blocks that are truly generic and safe to depend on. And if something’s missing, the open-source nature of the System Application means you can contribute improvements yourself.