How To Use Monitor for Microsoft Canvas Apps in the Power Platform

In our previous blog post about Canvas Apps, we discussed debugging formulas in Canvas Apps. While formula errors will present themselves immediately within your app editor, sometimes the app will not function as expected even though no errors are showing within the app. When this happens, Microsoft has a tool that allows you to trace what your app is doing: Monitor.

How To Set Up Canvas Apps

In order to use Monitor, you will first need to enable it for your Canvas Apps. Once you have created your app, you can enable Monitor by clicking the “Settings” button in the top ribbon, going to the “General” tab (it is selected by default, but that is where the setting is if you have navigated away from the tab), and then scrolling down to the Debug Published App setting. Setting that bit field to “On” will allow you to use Monitor after you publish your app.

Once the app has been published you will be able to launch Monitor by clicking the three-dot ellipsis icon next to your app on make.powerapps.com, and going to “Details”, then “Live Monitor”. From the top ribbon, click “Play Published App” to launch the app to get feedback from Monitor. This will launch the app in a new tab and show the debug information for your app in the existing Monitor tab.

Details Live Monitor Canvas Apps

How To Read the Data from Monitor in Canvas Apps

Immediately upon opening the app you will start seeing events being populated in Monitor. For this example, I am using an app that has one screen with a gallery that has all accounts in it, a text input field that populates the email of the gallery’s selected account, and a button to update the selected account’s email. When this app is loaded, I can see the App.OnStart event (this app doesn’t have anything in App.OnStart, but it still runs), a Navigate and LoadScreen event for my screen, and a getRows event to populate the gallery.

On the right-hand side of the screen there is a fly out menu for each event giving individual details. For events like the Navigate and LoadScreen there is not much exciting going on, just the name of the screen that is being loaded or navigated to and how long that action took to perform. Operations like getRows have much more robust feedback that can give us some insight into what is going on in our app though.

LoadScreen getRows Canvas Apps

In the “Details” tab of the fly out menu is a JSON object that is going to tell us everything we need to know about this getRows operation. For instance, we can see the data source for this retrieve is from the Accounts table, and that the control that it is going to populate is Gallery1.

getRows Details

Additionally, we can scroll down on the Details to the “Value” part of the JSON object to see what data is being returned to our gallery. In this case, our gallery is only populating the account name and email address into the gallery so the only columns the getRows operation is pulling back from this table is name, emailaddress1, and accountid (unique identifiers for the table you are retrieving data for are always returned).

How To Use Monitor to Fix Errors in Canvas Apps

So what happens if I run into an error? In this case, I am going to attempt to update the email of the first record in my gallery to something that really is not an email address, like the word “cat”. When I do this in Canvas Apps, all the feedback I get is that the Patch function I have on my button is invalid. This Patch function would work out of the box, but something else is going on in my environment that is preventing this update from going through, and the error the app is showing me does not really help me figure out what is causing the issue.

Canvas Apps Patch

Switching back to Monitor gives us the details we need to debug the error we are getting from our app. We can see the patchRow operation resulted in an error, and the JSON object for that patchRow, like the getRows, gives information on what control is being used to fire the update, what text is being fed into the Patch statement, and the formula of the Patch statement from the app. Most importantly though, we get the full body of the error that sheds light on what actually happened to block our update.

patchRow getRows JSON

The body of the error reveals where our error came from: Sync workflow ‘Validate Email Address’ and terminated with the error message “Invalid Email Address”. In this environment, there is a business rule on the account entity that is checking when an email address is updated and if it does not contain an ‘@’, it will throw the error “Invalid Email Address”. Although we do not see this within the app, we can look in Monitor to see the error message and take steps to mitigate it within the app. To prevent this error in the future, we can also add logic to disable the update button if the input text field does not contain an ‘@’.

By combining our formula debugging tips from our previous blog and using Monitor to debug published apps, you should be able to resolve most any Canvas Apps issue that comes your way. While a little setup and know-how is required to work with Monitor, it is a very powerful tool that can tell you a lot more about what your Canvas Apps are doing and how to resolve issues that they are experiencing.

Joshua Kranhold – Senior Consultant

Working with New Dynamic

New Dynamic is a Microsoft Solutions Partner focused on the Dynamics 365 Customer Engagement and Power Platforms. Our team of dedicated professionals strives to provide first-class experiences incorporating integrity, teamwork, and a relentless commitment to our client’s success.

Contact Us today to transform your sales productivity and customer buying experiences.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *