Show Error Dialog in Microsoft Dynamics CRM style using Xrm.Internal.openErrorDialog

By this time many of you might have already explored the Xrm.Internal namespace and displayed your custom webresources in CRM 2013/ 2015 modal style. Well, if you have not, I suggest you check my blog post https://debajitcrm.wordpress.com/2014/04/29/exploring-the-xrm-internal-namespace-in-crm-2013/ to explore the Xrm.Internal namespace and i bet you would like it.

Coming back to the topic, if we open our custom webresources in CRM modal style, why not show the custom client side errors in CRM 2013 style? If you are thinking how to to do this, you have to come back to Xrm.Internal namespace and explore its Xrm.Internal.openErrorDialog method.

First let us explore the Xrm.Internal.openErrorDialog method. The following is the nomenclature of this method.

function (errorCode,message,serializedException){var $v_0="0x"+(errorCode<0?4294967295+errorCode+1:errorCode).toString(16).toUpperCase();if(IsNull(serializedException))openErrorDlg($v_0,message,null,0,0);else openErrorDlgWithDetailedInfo($v_0,message,serializedException,0,0)}

So we can see that it accepts three parameters

  • Error Code
  • Message
  • Serialized Exception

Error Code : If you see the nomenclature, it appends “0x” to the error code. It should be a number. If you enter anything other than integer, the method might not work as expected.

Message: I have tried multiple combinations but whatever i entered does not reflect. However if anybody reading this can explore this, it would be extremely beneficial.

Serialized Exception: This is the most important parameter. Whatever value you put here is the one that would come when the user clicks on “Download Log file” button.

As an example, in the account form load, I have called the method as shown in the screenshot below.

image

 

Now when the form loads, the following error message is displayed. When the user clicks on ‘Download Log File’ you can see the Downloaded error message.

image

Hope this helps!

Advertisements

Author: Debajit

I am a Dynamics CRM Most Valuable Professional (MVP) with 10 years of experience in Microsoft .NET Technologies and 7 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

4 thoughts on “Show Error Dialog in Microsoft Dynamics CRM style using Xrm.Internal.openErrorDialog”

  1. Pingback: CRM Backlog
  2. Pingback: CRM Backlog

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s