Error Management in PowerApps/ Dynamics 365 Portals – A complete guide

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

So readers, I am back with another blog. And quite rightly, a blog on PowerApps portals. In this blog I am going to discuss about a pretty important topic – “Error handling in PowerApps portals”. A topic which will excite developers, consultants, administrator or I shall say even customers.

So let me start with the agenda here. We will start with very generic error handling mechanisms that portal provide. Followed by some extensibility features and finally to some quite specific.

Disable/ Enable custom errors.

This is probably your first place where you land up to manage and configure error handling for your portals. And how can you land up here? All you need is to navigate to PowerApps maker portal -> Select your portal -> Click on Settings from the Menu -> Administration

PowerApps Portal Checker
PowerApps Portal Checker

Click on Portal Actions on left hand navigation and you will find an option to Disable custom errors. This is the default configuration for a PowerApps or erstwhile Dynamics 365 portal.

But before I go ahead and use this option, let me explain what this option does. If you are facing any runtime issue in a portal and you have custom errors enabled, you will notice the below error screen.

Well, in times of difficulty, this can hardly be your friend. After all there is nothing much you get from the above screen. Some error ID with which may be only Microsoft support can help you out.

Usually when I explain this, I get a question. Can I customize this custom error HTML or is it the only thing I have to live with? Fortunately you have the option to customize the custom error dialog.

The error message is based on a content snippet of type HTML. To customize and show custom HTML, the procedure is described here.

Coming back to the topic here. Let’s go ahead and Disable custom errors. You will get an confirmation to proceed with disabling.

Click on Disable to disable custom errors. There is a very important message in the confirmation dialog. The message says – “This action will restart the portal and it will be unavailable for a few minutes”. But why is this important? Remember it says the portal will be restarted. So whenever you do this, make sure you intimate your users about the downtime, especially if you are doing this in production. As expected, the option now changes to – “Enable custom errors”.

Once custom errors is enabled, if you get an error in the portal, you will start seeing the age old yellow ASP.NET error page. Obviously it does not make much of a sense to show to the end users. But when something goes really weird and you are unable to trace, this can be really beneficial.

Pic courtesy : Microsoft Docs

You will also like the below posts

Enable Diagnostic Logging

This is the second option and probably the most used one. And the reason for this is because of the flexibility it offers. While disabling custom errors is a good option, it is not ideal for production environments. After all, you would not like your end users to see the ugly yellow error screen.

The next question is how we can achieve the best of both the worlds? How can we get the actual error and still go ahead and display a custom user friendly message to the end users? Well, the answer to that is enabling diagnostic logging in the portal.

To enable diagnostic logging, you need to login to Power Portal Admin center (check the procedure as explained earlier in the blog) and then click on “Enable Diagnostic Logging.”

For the brevity of this blog, I have explained in detailed on diagnostic logging in this blog. Before I close off on the diagnostic logging section, remember diagnostic logging uses the Azure storage. And diagnostic logging is pretty extensive as well. So turning it on and keeping it like that may incur significant cost on your azure storage.

Display Plugin/ Workflow errors on Portals

This is a developer’s delight. Why? Because whether you are working in CDS or Dynamics 365, chances are you will end up writing some plugins/ workflow for custom business logic. And since this is custom code, it is expected that there will be issues.

You might be thinking, what is the big thing about this? Haven’t we discussed already enough on error logging? Yes we have discussed enough but still there are some interesting points to cover.

What if you do some portal operation which trigger a plugin. The plugin code generate an error and you want to see the error in the portal. We already know by now that disabling custom error in production environment is not a solution. So we keep custom errors enabled.

Now the next option is to enable diagnostic. With diagnostic logging, the error will get logged but the end user will still see custom error message. Once they report the error, you would go ahead and dig in the extensive logs to get hold of the issue.

What if we could have avoided this and make sure that any error appearing from custom code would be immediately shown to the user even though custom errors are enabled? This would greatly reduce the support time. The customer can now just forward you the actual error message. And all this without seeing the ugly yellow colour ASP.NET error page.

You may be thinking, that’s quite an effort. Contrary, it’s just changing a small setting. To accomplish this, navigate to PowerApps maker portal, select “Portal management” app and then click on Play

You may find the name of the app as “Dynamics 365 Portals” as well. It’s basically the same app.

Click on Site Settings under Website section and create a new site setting with the below details

  • Name – Site/EnableCustomPluginError
  • Value – true

Make sure that the setting is not already in place before your create it. If it is already in place, set the value to true.

Save the changes. You have to refresh your portal cache for the changes to be reflected in the portal. Now whenever there is an error arising out of custom code, it will show up in the portals.

Check out my recent posts

Hope this helps!
Debajit Dutta
(Business Solutions MVP)


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading