Editar

Partilhar via


openAlertDialog (Client API reference)

Displays an alert dialog containing a message and a button.

Syntax

Xrm.Navigation.openAlertDialog(alertStrings,alertOptions).then(successCallback,errorCallback);

Parameters

Note

With the new look enabled, dialog height will resize automatically if you don't set the height value of the dialog options.

Name Type Required Description
alertStrings Object Yes The strings to be used in the alert dialog. The object contains the following values:
- confirmButtonLabel: (Optional) String. The confirm button label. If you don't specify the button label, OK is used as the button label.
- text: String. The message to be displayed in the alert dialog.
- title: (Optional) String. The title of the alert dialog.
alertOptions Object No The height and width options for alert dialog. The object contains the following values:
- height: (Optional) Number. Height of the alert dialog in pixels.
- width: (Optional) Number. Width of the alert dialog pixels.

With the new look enabled, dialog height resizes automatically if you don't set the height value of the dialog options.
successCallback function No A function to execute when the alert dialog closes either clicking the confirm button or canceled by pressing ESC.
errorCallback function No A function to execute when the operation fails.

Example

The following sample code displays an alert dialog. Clicking Yes button in the alert dialog or canceling the alert dialog by pressing ESC calls the close function:

var alertStrings = { confirmButtonLabel: "Yes", text: "This is an alert.", title: "Sample title" };
var alertOptions = { height: 120, width: 260 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
    function (success) {
        console.log("Alert dialog closed");
    },
    function (error) {
        console.log(error.message);
    }
);

Xrm.navigation