Sunday 11 February 2018

Show Custom Error Message in CRM Portal






While working on Dynamics 365 Portal, We all have observed an error message is displayed like below when an error occurred in Portal Add-on.

"We're sorry, but something went wrong. Error ID #[<GUID>]"

"An unknown failure has occurred. Error ID # [<GUID>]"




















But they're quite unclear, so users cannot take any action based on this message. GUID doesn't help.

If there's certain contact such as e-mail address of Portal admin, the error message should contain this information and suggest to contact to admin.

These type of errors usually comes when any CRM Plugins/Workflows throw the Server-Side error while processing the Portal requests.

Currently, Microsoft has not provided any direct way to customize this error message. Though a lot of people submitted their ideas on Microsoft Idea Portal to addon this feature in upcoming portal releases.

https://ideas.dynamics.com/ideas/dynamics-crm/ID0000538


Solution:

Though we do not have any direct way to achieve this, so I have written 2-3 lines of script. Using that you can show the user-friendly error message to the portal users.


$(window).load(function()
{
      // You just need to Change the error message only

      var errorMessage = "We're experiencing an internal server problem. Please try again later or contact support@help.com";
     
      $('.text-danger').html('<span class="fa fa-exclamation-triangle" aria-hidden="true"></span>&nbsp'+errorMessage);

});


In the above code, you just need to change the error message and paste the whole code inside Custom JavaScript section of the Web page.










Demo:












1 comment:

  1. Hi Arpit, this is a great post. But for some reason, I'm not able to make it work. I'm trying to display a custom error on triggering a WF (when the WF is cancelled). Any help reg this is much appreciated!!!
    Thanks,
    Dhivya

    ReplyDelete

Blogger Widgets