Dynamics 365 Business Central: How to create Message Box with Timer (Close a Message Box after several seconds)

Dynamics 365 Business Central

Hi, Readers.
I saw a very interesting question a few days ago, is it possible to create a message box with a timer in Business Central? They want to close a message after 10 seconds.

Yeah, although we can’t do a perfect one, we can easily do a similar one.😃

Test Video:

How is this done?
This time we can use Dialog data type.
Dialog.Open Method: Opens a dialog window.
Dialog.Update Method: Updates the value of a ‘#’-or ‘@’ field in the active window.
Dialog.Close Method: Closes a dialog window that has been opened by the OPEN method.
These methods are mainly used to create a progress bar in Business Central.
More details: Progress indicator (Progress bar)

The following is a very simple example:

On the page:

PS: System.Sleep Method: Returns control to the operating system for a specified time.

Source Code:

pageextension 50100 SalesOrderListExt extends "Sales Order List"
{
    actions
    {
        modify("Print Confirmation")
        {
            trigger OnBeforeAction()
            var
                MyDialog: Dialog;
                MyNext: Integer;
                Text000: Label 'The reports in the 204-207 range are replaced by the following updated reports in the 1304 to 1307 range.\.\.\.\This message will be closed in 10 seconds.\#1';
            begin
                MyNext := 11;
                MyDialog.Open(Text000, MyNext);
                repeat
                    Sleep(1000);
                    MyNext := MyNext - 1;
                    MyDialog.Update();
                until MyNext = 1;
                MyDialog.Close();
            end;

        }
    }
}

Note: There is no OK button in the Dialog, only Cancel, which means you can cancel the process midway, but you cannot click OK to continue.

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL