Single post - 1



Alert, confirmation, error pop-up in Dynamics 365(V9.0)

xml

While working with latest version of CRM (Dynamics 365 v9.0) found some excited features such as dialog alerts using client side navigation. Dynamics 365 v9.0 has introduced Xrm.Navigation namespace under Xrm object. It has a mix of new methods and old methods moved from Xrm.Utility.

Previously we had Xrm.Utility.alertDialog which did not have that much features and in Web Client showed as the plain old alert, which was the same as from standard JavaScript “alert” function. Right now the alert is much better on look and feel.

New methods which we can use are the following:
openConfirmDialog
openAlertDialog
openFile
openErrorDialog
openUrl
openForm
openWebResource

Let’s look one by one on each of them with the help of example.

1. Xrm.Navigation.openConfirmDialog


var ConfirmString =
{
text: “Are you sure want to Approve?”,
title: “Confirmation Alert”,
subtitle: ” This Account is Requested to Delete”,
confirmButtonLabel: “Approve”,
cancelButtonLabel: “Cancel”
};
var OptionalParameter = { height: 200, width: 400 };
Xrm.Navigation.openConfirmDialog(ConfirmString, OptionalParameter).then(
function (success)
{
},
function (error)
{
var ErrorDetails = error.message;
Xrm.Navigation.openAlertDialog({ text: ErrorDetails });
});


approve


2. Xrm.Navigation.openAlertDialog:


var alertStrings =
{
confirmButtonLabel: “Okay”,
text: “Please fill up Rejection Remarks for Request to delete”
};
Xrm.Navigation.openAlertDialog(alertStrings).then(
function () { console.log(“Dialog was closed”); },
function () { console.log(“Something went wrong”); });


okay


3. openFile


var file =
{
fileContent: “bXkgc2VjcmV0IGNvbnRlbnQ=”, //Contents of the file.
fileName: “DownloadFileSample.txt”, //Name of the file.
fileSize: 24, //Size of the file in KB.
mimeType: “text/plain” //MIME type of the file.
}
Xrm.Navigation.openFile(file, 2);


download file


4. openErrorDialog


var errorOptions =
{
details: “Click on Download Log File to download error log file. ‘Download Error log file’”,
errorCode: 666, //this is error code if you want to show some specific one. If you specify invalid code or none, the default error
code wouldbe displayed
message: “Message show in the dialog”
};
Xrm.Navigation.openErrorDialog(errorOptions).then(
success => {console.log(“Dialog was closed successfully”);},
error => {console.log(error);});


error log file


5. openUrl


var url = “https://community.dynamics.com”;
var openUrlOptions = {
height: 500,
width: 900
};
Xrm.Navigation.openUrl(url, openUrlOptions);


open url


6. openForm


var entityFormDetails = {
entityName: “contact”,
useQuickCreateForm: false
};
var newFormParameters = {
fullname: “Contact example”,
jobtitle: “Manager”,
emailaddress1: “abc@email.com”,
telephone1: “7658423692”,
description: “Using this function we can auto populate values on new form”
};
Xrm.Navigation.openForm(entityFormDetails, newFormParameters).then(
success => { console.log(success); },
error => { console.log(error); });


openform


7. openWebResource


var windowPopupOptions = {
openInNewWindow: false,
height: 500,
width: 500
};
Xrm.Navigation.openWebResource(“new_testhtmlpage”, windowPopupOptions, “someAdditionalParameter”);
Sample HTML code:
Hi this is test HTML page


web


Be ready for new features and enjoy this feature of dynamics 365 v9.0
Hope this help you !!!
Thank you.

Pravin Pawar
NSquare Xperts
www.nsquarexperts.com