{"id":16788,"date":"2021-10-07T09:00:00","date_gmt":"2021-10-07T16:00:00","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/canvas-app-troubleshooting-part-1\/"},"modified":"2021-10-07T09:00:00","modified_gmt":"2021-10-07T16:00:00","slug":"canvas-app-troubleshooting-part-1","status":"publish","type":"power-apps","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/canvas-app-troubleshooting-part-1\/","title":{"rendered":"Canvas App Troubleshooting – Part 1"},"content":{"rendered":"
In this blog series, we’ll discuss some strategies our support team use when troubleshooting issues in canvas apps. We’ll focus on strategies that any app maker can use to diagnose and fix issues in their apps. To illustrate, let’s start with a scenario.<\/p>\n
Let’s say you have a gallery, and the Items property for the gallery is something like this:<\/p>\n
Where MySharePointList is a SharePoint list containing Departments in your company, and cmbContacts is a Combo box of possible department contacts, populated from an Excel spreadsheet.<\/p>\n Problem: the gallery isn’t showing any records. What could be causing this?<\/p>\n <\/p>\n In the Filter() statement, we have three elements:<\/p>\n Let’s interrogate each of these elements<\/p>\n This should be an easy test. In our example, we can simply set the gallery’s Items property to MySharePointList (no filter). If the unfiltered datasource populates some items in the gallery, then we know that there are rows present.<\/p>\n <\/p>\n Looking good!<\/p>\n It’s important to validate that the ContactEmail has some data in it, and what kind of data is in the column. You can actually see this data in the previous screenshot, but sometimes it helps to go right to the datasource (SharePoint) and see what’s present.<\/p>\n <\/p>\n Now we know that this ContactEmail column has three possible values: andrea@contoso.com, bill@contoso.com, or marie@contoso.com.<\/p>\n To check this, create a label and set its text property to cmbContacts.Selected.Email, so we can validate if that Email value looks correct.<\/p>\n Uh oh! That doesn’t look right. We have differing values for cmbContacts.Selected.Email and ContactEmail:<\/p>\n This seems to be our problem. If we investigate further, we’ll find that, while the SharePoint list has recorded the email address of these users, the Excel spreadsheet I used to populate my Combo box\u00a0actually<\/em>\u00a0has the users’ UPNs, and those are not the same!<\/p>\n Here I want to introduce one of the sharpest tools in our toolbelt: Power Apps Monitor. There are resources available on Monitor, so I won’t go into every detail of using it.<\/p>\n Here I want to introduce one of the sharpest tools in our toolbelt: Power Apps Monitor. There are resources available on Monitor, so I won’t go into every detail of using it.<\/p>\n Debugging canvas apps with Monitor<\/a> In our case, we want to capture a monitor trace while our gallery is loading, and try selecting some different filters via the Combo Box.<\/p>\n Once we have that captured, look for rows in the Monitor trace where the Control column matches our gallery’s name, and the Property column says “Items”. In my case, that would be the rows highlighted:<\/p>\n <\/p>\n You will see that in my case these rows are coming in pairs. By clicking on a row with Operation “getRows”, I can see much more detail about the request to get this data from SharePoint.<\/p>\n <\/p>\n I want to draw attention to the highlighted section on the right. This is the actual HTTP request the Power App is making to fetch relevant records from SharePoint. It looks a bit messy, but if we run it through a URL decoder a few times, we can get a legible result (I’ll be removing the SharePoint domain and replacing it with <MyDomain>):<\/p>\n This entire URL is packed with interesting information, but the part after “datasets\/” is what concerns us right now.<\/p>\n Here, you can see exactly the filter that is going to be applied when we query SharePoint:\u00a0 And compare it to what the filter\u00a0should<\/em>\u00a0be:<\/p>\n This scenario is inspired by a real case that came to our support team recently. The customer found themselves in a scenario I’m sure many are familiar with – supporting an app that was authored by someone else, with little documentation on how the app works. Of course, it would be easier if the app had come with documentation or robust inline comments, but often that is not the case.<\/p>\n The solution to this issue was ensuring that both sides of the Filter() expression were using the Email address, rather than one using Email and the other using UPN. In the course of troubleshooting, there were other possible causes we had considered, including:<\/p>\n If the equality of ContactEmail and cmbContacts.Selected.Email were\u00a0not<\/em>\u00a0the problem, then we would be in the realm of “issues that may not have a simple explanation”. If you find yourself reaching that point, it would definitely make sense to reach out to us at the Support team!<\/p>\n","protected":false},"excerpt":{"rendered":" Take the first steps in self-diagnosing and mitigating issues in your apps.<\/p>\n","protected":false},"author":255,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","power-apps-category":[1664,1703],"power-apps-tag":[],"coauthors":[2221],"class_list":["post-16788","power-apps","type-power-apps","status-publish","hentry","power-apps-category-uncategorized","power-apps-category-support"],"yoast_head":"\nFilter(MySharePointList, ContactEmail=cmbContacts.Selected.Email)<\/code><\/p>\n
Break the formula into component parts<\/h2>\n
\n
Does the datasource have any rows that Power Apps can see?<\/h3>\n
What data does the ContactEmail column contain?<\/h3>\n
What is the value of cmbContacts.Selected.Email?<\/h3>\n
\n
Taking it one step further<\/h2>\n
\nCollaborative troubleshooting using Monitor<\/a>
\nAdvanced monitoring concepts<\/a><\/p>\nhttps:\/\/unitedstates-002.azure-apim.net\/apim\/sharepointonline\/<connectionId>\/datasets\/https:\/\/<MyDomain>.sharepoint.com\/sites\/TomJ\/tables\/949a20cb-5647-436f-a696-f609ea26a8f0\/items?$filter=ContactEmail eq 'Andrea.R@contoso.com'&$top=100<\/code><\/p>\n
https:\/\/<MyDomain>.sharepoint.com\/sites\/TomJ\/tables\/949a20cb-5647-436f-a696-f609ea26a8f0\/items?$filter=ContactEmail eq 'Andrea.R@contoso.com'&$top=100<\/code><\/p>\n
ContactEmail eq 'Andrea.R@contoso.com'<\/code>. All it would take is a quick glance at SharePoint to confirm that there aren’t any items that will fulfill this condition. With a little knowledge of the SharePoint REST API, I can even turn this into an API query I can run in my browser:<\/p>\n
https:\/\/<MyDomain>.sharepoint.com\/sites\/TomJ\/_api\/web\/lists(guid'949a20cb-5647-436f-a696-f609ea26a8f0')\/items?$filter=ContactEmail%20eq%20%27Andrea.R@contoso.com%27<\/code>
\n<\/p>\nhttps:\/\/<MyDomain>.sharepoint.com\/sites\/TomJ\/_api\/web\/lists(guid'949a20cb-5647-436f-a696-f609ea26a8f0')\/items?$filter=ContactEmail%20eq%20%27Andrea@contoso.com%27<\/code>
\n<\/p>\nTakeaways<\/h2>\n
\n