D365 V9{Upgrade}: Client API update for alert and confirm

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);

a

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.
});

b

Hope it helps !!

Advertisements

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 )

Google+ photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s