In D365 V9, as per Microsoft documentation, Xrm.Utility.alertDialog() should be replaced by Xrm.Navigation.openAlertDialog() and Xrm.Utility.confirmDialog() should be replaced by Xrm.Navigation.openConfirmDialog().
Let’s take an example of both alert and confirm dialog box and see what exact changes we need to do in JS code apart from the above library change.
alert:
D365 V8:
Xrm.Utility.alertDialog("Message");
D365 V9:
var alertStrings = { confirmButtonLabel: "OK", text: "Cancel Button Pressed" }; var alertOptions = { height: 100, width: 400 }; Xrm.Navigation.openAlertDialog(alertStrings,alertOptions);
confirm:
D365 V8:
Xrm.Utility.confirmDialog(message, function(){ //Do something on click of OK. });
D365 V9:
var confirmStrings = { text: "Do you want to change case status to 'Accepted (Closed)'.", title: "Confirmation Dialog" }; var confirmOptions = { height: 200, width: 460 }; Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then( function (success) { if (success.confirmed) { //Do something on click of OK. } else //Do something on click of Cancel. });
Hope it helps !!