Microsoft Dynamics 365 v9.0 – Xrm.Navigation Namespace

, January 18, 2018 5289 Views

The Xrm.Navigation Namespace is a new namespace, a new feature of Dynamics 365 V9.

This namespace consists of previously known functions such as:-
openAlertDialog, openConfirmDialog, openWebResource, & openForm

And it is also having two new functions:-
openErrorDialog & openUrl

Here in this blog, I will explain you how to use the openErrorDialog & openUrl functions of the Xrm.Navigation Namespace.

Below is the JavaScript code, where, when the user enters a special character in the Name field, an error pop-up will be opened and if the user enters a valid string as Name, then a URL will be opened in a new window.

// JavaScript source code
function xrmNavigationFunctions() {
    var errorOptions = {
        details: "The name is having special character in it. Please enter another name.",
        message: "Error"
        // errorCode :  The error code. 
        // If you just set errorCode, the message for the error code is automatically 
        // retrieved from the server and displayed in the error dialog. 
        // If you specify an invalid errorCode value, an error dialog with a default error message is displayed.
    var openUrlOptions = {
        height: 800,
        width: 800
    var sportsName = Xrm.Page.getAttribute("new_name").getValue();
    var specialCharacters = "@.~`!#$%^&*+=-[]\\\';,/{}|\":<>?";
    var isValidName = true;

    for (var i = 0; i < sportsName.length; i++) {
        if (specialCharacters.indexOf(sportsName.charAt(i)) != -1) {
            isValidName = false;
                function () {
                function () {
                    // Something went wrong

    if (isValidName == true) {
        Xrm.Navigation.openUrl("https://en.wikipedia.org/wiki/Sport/", openUrlOptions)

Here, the errorOptions is an object that defines all the options for the openErrorDialog function.

Note:- You must either set the errorCode or message attribute for the openErrorDialog function. Otherwise, an error will be thrown.

When the user enters a special character in the Name field, an error pop-up will be opened as follows:-

When the user clicks on the OK button, he/she will see that the Name field has become blank (as per our JavaScript code)

And, if the user clicks on the Download Log File button. A file will be downloaded, open the downloaded file. He/she will see in it, the message specified in the details attribute of the errorOptions object.

In this way you can open an error pop-up using the Xrm.Navigation.openErrorDialog function.

And, the OpenUrlOptions is an object that defines all the options for the openUrl function. Like, the height & width option will set the height and the width of the error pop-up.

If the user enters a valid string in the Name field, then a URL(as specified in JavaScript code) will be opened in a new window.

In this way you can open a URL using the Xrm.Navigation.openUrl function.

I Hope this helps you…

Happy CRMing!!


Insert data into Many-to-Many relationship in Dynamics CRM very easily & quickly, using the Drag and drop listbox.



INKEY is your solution partner.
Our focus is to deliver you in-time intelligent innovative solutions ("key") for the problems in hand. Maintaining a quality standard right from the inception of a project is our top most priority.

Our team of talented professionals will execute your projects with dedication and excellence. We take ownership and accountability for the effort that goes into meeting our client’s needs.

Years of experience and proven success of delivering innovative custom solutions.

More posts by

Leave a Reply

Your email address will not be published.

The maximum upload file size: 2 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Drop file here