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!
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.
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:
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.
You can filter these items to only show failures which gives you a far better indication of when and why issues are occurring.
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.
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!
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