AX / D365FO – Displaying a Message Box in X++ #d365fo #ax #msdyn365fo

Box Class Methods

The following table describes the Box class methods and their associated DialogBoxType system enum values.

Box class static method nameAssociated DialogBoxType enum valueDescription
infoInfoBoxThe OK button is the only one that the info method displays in the dialog box.Use this method to display general information messages rather than for warning or error messages.
infoOnceInfoBoxThe infoOnce method is similar to the info method but with the following differences:Your code cannot set the text in the title bar.An additional header section is displayed under the title bar, and you can set the text that displays in the header.A More info… button is present. When clicked, it opens a Web browser to the URL string that you supply through a parameter.The infoOnce method returns void, even though it has two buttons.
infoOnceExInfoBoxThe infoOnceEx method is similar to the infoOnce method but with the following differences:The infoOnceEx method has a parameter that can be passed in to set the text in the title bar.The infoOnceEx method has a Boolean parameter for choosing whether to have the caller thread continue processing while the user reads the message in the dialog box.
okCancelOkCancelBoxThe OK and Cancel buttons are displayed in the dialog box. Call this method when the user must confirm or reject an action.
stopStopBoxThe OK button is the only one displayed in the dialog box.Use this method to display a message when the user should stop attempting their action or when a process has stopped running.
warningWarnBoxThe OK button is the only one displayed in the dialog box. Use this dialog box for a warning message.
yesAllNoAllCancelYesToAllNoToAllBoxThe buttons displayed in this dialog box are YesYes to allNoNo to all, and Cancel.
yesNoYesNoBoxThe buttons displayed in this dialog box are Yes and No. Call this method when you need the user to make a choice.
yesNoNoAllCancelNoToAllBoxThe buttons displayed in this dialog box are YesNoNo to all, and Cancel.
yesNoAxaptaFormYesNoBoxThe yesNoAxaptaForm method is similar to the yesNo method but with the following differences:The yesNoAxaptaForm dialog box has a different image.The yesNoAxaptaForm dialog box is wider.
yesNoCancelYesNoCancelBoxThe buttons displayed in this dialog box are YesNo, and Cancel. Call this method when the yesNo method is insufficient.
yesNoOnceYesNoBoxThe yesNoOnce method is similar to the yesNo method but with the following differences:The yesNoOnce dialog box has a different image.The yesNoOnce dialog box has a check box that the user can select to suppress any further occurrence of an associated message.
yesYesAllNoCancelYesToAllBoxThe YesYes to allNo, and Cancel buttons are displayed.

Example

The following example displays a message box that contains buttons labeled YesNo, and Cancel. The No button has initial focus. When a button is clicked, a message is displayed in the Print Window to indicate which button was clicked. Run this example as a job in the Application Object Tree (AOT).X++Copy

    static void JobBoxDemo(Args _args)
    {
        DialogButton diagBut;
        str strMessage = "The No button should have initial focus.";
        str strTitle = "Title";
        ;
        diagBut = Box::yesNo(
            strMessage,
            DialogButton::No, // Initial focus is on the No button.
            strTitle);
        if (diagBut == DialogButton::No)
            {
                print "The No button was clicked.";
            }
        else
            {
                print "The button that was clicked was: ", diagBut;
            }
        pause;
    }

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 )

Facebook photo

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

Connecting to %s