Edit

openConfirmDialog (Client API reference)

Displays a confirmation dialog box containing a message and two buttons.

Syntax

Xrm.Navigation.openConfirmDialog(confirmStrings,confirmOptions).then(successCallback,errorCallback);

Parameters

Note

When you enable the new look, the dialog height resizes automatically if you don't set the height value of the dialog options.

Name Type Required Description
confirmStrings confirmStrings Yes The strings to use in the confirmation dialog.
confirmOptions confirmOptions No The height and width options for the confirmation dialog.
successCallback function No A function to execute when the confirmation dialog is closed by clicking the confirm, cancel, or X in the top-right corner of the dialog. An object with the confirmed (Boolean) attribute is passed that indicates whether the confirm button was clicked to close the dialog.
errorCallback function No A function to execute when the operation fails.

confirmStrings

Name Type Description
cancelButtonLabel String (Optional) The cancel button label. If you don't specify the cancel button label, Cancel is used as the button label.
confirmButtonLabel String (Optional) The confirm button label. If you don't specify the confirm button label, OK is used as the button label.
subtitle String (Optional) The subtitle to display in the confirmation dialog.
text String The message to display in the confirmation dialog.
title String (Optional) The title to display in the confirmation dialog.

confirmOptions

Name Type Description
height Number (Optional) Height of the confirmation dialog in pixels. With the new look enabled, the dialog height resizes automatically if you don't set the height value of the dialog options.
width Number (Optional) Width of the confirmation dialog in pixels.

Example

The following code sample displays a confirmation dialog box. It logs an appropriate message in the console depending on whether the user selects confirm or cancel/X to close the dialog.

const confirmStrings = {
  text: "This is a confirmation.",
  title: "Confirmation Dialog"
};
const confirmOptions = { height: 200, width: 450 };

Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(({ confirmed }) => {
  if (confirmed) {
        console.log("Dialog closed using OK button.");
  } else {
        console.log("Dialog closed using Cancel button or X.");
  }
});

Xrm.Navigation