Using ‘Monitor’ to Troubleshoot Power Apps Errors

This week I made a mistake in a Canvas App. It happens.

I was using the TimeZoneOffset function in a larger Power Fx formula to calculate the local time for our colleagues across the pond, and for some reason I decided to include the current date as a variable inside the function unnecessarily. I don’t know why, it just happened!

...TimeZoneOffset(Today())...

There’s no need for this. TimeZoneOffset returns the quantity of minutes between UTC and the logged in user’s time zone in usual circumstances.

Now the interesting thing here is that I wasn’t getting an error whilst building, saving, or publishing my Canvas App in the Power Apps Studio or even when pressing the Play button, but every time the app loaded as a published app then they would receive an error.

A screenshot of my app showing the TimeZoneOffset error whereby my larger Power Fx function expected a DateTime value and not null.

This is because the function was returning null instead of the offset in minutes, so technically the formula was executing. It’s just that the type was incorrect.

Monitor Power Apps

I’ve never faced a scenario in the past like this before, and if it wasn’t for the ‘Monitor‘ function in the Power Platform then I would have found it far more difficult to locate where the error was being caused and our error may have frustrated users for much longer than it actually did.

To use Monitor, you can head over to https://make.powerapps.com, select your app, and the ‘Monitor’ button will show in the navigation bar as shown below:

You can also do this for Model-driven Apps in your list, but it’s less common in today’s world with code being written less and less as people move away from C# and JavaScript towards the configurable options in Dataverse.

A screenshot of https://make.powerapps.com showing the Apps area from the navigation, with the Monitor button highlighted on the screen in the navigation bar.

When you open Monitor, you’ll see a blank screen and a ‘Play Published App’ button, and when you interact with your app on the screen it will show you all of the executed functions along side their success/failure status with a whole host of other details to help you identify where something is going wrong.

A screenshot of the Monitor screen after actions have been executed within the app itself, showing a series of successes and failures.

You can filter these items to only show failures which gives you a far better indication of when and why issues are occurring.

A screenshot of the Monitor screen filtered by events that ended up with a failure status.

I started to notice a trend, and the number of failures shown was always exactly double the number of All Day events I was trying to render on the screen. By clicking on any given error, it provides you with further details.

A screenshot of the error detail, showing that LblEnd was causing the issue.

As you can see from the screenshot, it was LblEnd that was causing the issue. This was the first control on the screen to use the output of the TimeZoneOffset result as it was displaying the end time of the appointment (start wasn’t important at this point!), and therefore I knew straight away that I simply needed to troubleshoot this line of Power Fx further in order to identify the error, which brings me nicely back to my troublesome mistake that I mentioned at the beginning of the post!

Conclusion

The Monitor tool is one of those features that just seemed to pop up out of nowhere in the Power Platform ~2 years ago, and personally I didn’t see a huge fanfare about it when it was released and have rarely used it.

Whilst both types of Power Apps go a long way to help you to troubleshoot errors before you publish your customisations & configuration, this can act as a safety net for any unhandled exceptions that the usual app checkers can’t catch.

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 )

Facebook photo

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

Connecting to %s

Create a website or blog at WordPress.com

%d bloggers like this: