DYNAMICS 365 HOW TO SHOW GLOBAL NOTIFICATION FROM ENTITY VIEW

In this previous post, I described how to show a global notification in the model-driven app from within an event handler on the form and we saw the different options and possibilities that we can do with this functionality.

In this post, I will show you how to display a notification from any entity view instead of the form level.

For example, if you want to show the number of pending tasks to the user or the number of opened opportunities that should be closed and maybe allow the user to click the action button and be redirected to the appropriate screen.

Let's see how!
  1. First, create a new solution and add the Application ribbon component in it
  2. From the Ribbon Workbench, open the solution
  3. Scroll to the right, and add a new button under the Home menu in Mscrm.HomepageGrid.{!EntityLogicalName}.MainTab section
    Show global notification

  4. Create the command for the button as per the below image Show global notification 2

  5. Add an Enable rule with a Custom rule for the command as per the below image Show global notification 3

  6. Once done, publish your changes and open the model-driven app. The button will be added to all the entity views but it will not appear. However, the function you called in the custom JavaScript rule will be executed and will display the global notification
  7. Finally, I will put the sample code of the previous post to show a global notification message, where you can change it in order to do display the message and do the proper action based on your needs

    function showGlobalNotif(context) {
    var formContext = context.getFormContext();
    // define action properties
    var objAction =
    {
    actionLabel: "Click to do something",
    eventHandler: function () {
    Xrm.Navigation.openUrl("https://docs.microsoft.com/en-us/");
    // perform other operations as required on clicking
    }
    };

    // define notification properties
    var objNotification =
    {
    type: 2,
    level: 4, // 1: Success, 2: Error, 3: Warning, 4: Information
    message: "This is an Information global notification text.",
    showCloseButton : true,
    action: objAction
    };

    Xrm.App.addGlobalNotification(objNotification).then(
    function success(result) {
    // add code on notification display
    },
    function (error) {
    // add code to handle error
    }
    );
    }


Hope This Helps!

Comments

Popular posts from this blog

DYNAMICS 365 HOW TO HIDE RECENT RECORDS FOR LOOKUP FIELD IN UCI

SEARCH BY GUID IN DYNAMICS 365

SAVE FORM IN DYNAMICS 365 JAVASCRIPT