User Review
( votes)There are few products within the Microsoft Power Platform lineup that are as flexible (or as frustrating) as Canvas Apps. While Canvas Apps allow you to create almost any interface or navigation path you could possibly want, they can also come with some of the most vague and unhelpful errors imaginable. We would like to kick off a series discussing how to debug such issues within Canvas Apps, beginning with fixing formula errors of an app.
Something that we frequently use formulas for is the visibility of controls or the conditional formatting of text within Canvas Apps. Depending on how many conditions you may want to use as a criterion for this logic, these formulas can become complicated very quickly. Additionally, the normal interface can leave a bit to be desired when it comes to readability. Take the following screenshot as an example:
In this image, the formula above is formatting the text in red within the canvas to either be “Please choose a value over $99.99” if a value under a $100 is entered, “Please enter a value for lump sum payment #1” if a date is entered with no currency value, or to show no text if both of those tests are valid. But what if we had made a mistake in the formula, like forgetting one of the close parentheses?
If you have not done a lot of Canvas Apps, an error like “Invalid number of arguments” probably does not immediately read like something that says “you forgot to close a parentheses”, does it? Furthermore, clicking into the “View Problems” link does not direct you to where the issue actually is. So, how do we debug this?
First, take a close look at your formula for things like missing parenthesis or commas. Clicking on a parenthesis in the formula bar can help with this process since the formula bar will highlight its matched pair within the formula. In this case, we can see that the Is Blank function that is checking the value of txt_LumpSum1Payment is not being closed off where it should be, so adding a parenthesis will resolve the issue. See below.
When it comes to missing commas, Canvas Apps’ function bar has built in IntelliSense to show what arguments each formula takes. While this will not explicitly tell you where a comma is missing, it can be used to see if too many or too few arguments are present in a formula. IntelliSense is triggered when a formula is first written out and each time a comma is added to a formula. If you need to quickly check the IntelliSense for a formula, try removing and readding a comma from a formula.
Something to get into the habit of doing is using the “Format Text” button at the bottom of the formula bar. While writing formulas in this manner does convert your text, it also takes up a more space on the screen. This will make spotting errors significantly easier than it is with potentially several nested formulas crammed together into one or two lines of text.
For the most part, issues with formulas come down to missing elements from a formula such as commas and parentheses. While there are tools to help debug these issues, like IntelliSense and highlights for parentheses, it is not always obvious how they can be used. Hopefully you found this article useful and we look forward to our next one about Monitor and Canvas Apps.
By 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.
The post How To Debug Canvas Apps Formulas in the Microsoft Power Platform appeared first on CRM Software Blog | Dynamics 365.