Tips for Troubleshooting PowerApps Expressions

Introduction

In this post, we outline our three step process for troubleshooting issues in PowerApps Expressions:

  1. Identifying

  2. Inspecting

  3. Resolving

This step-by-step guide will help you manage the errors you find in the apps you create (or errors created by other people that you find yourself fixing).

Note: We are using the Site Inspection Template App in our screenshots - it doesn’t contain any errors out of the box. We have added problematic features into our instance of the app for the purpose of this article. :)

Step 1: Identify

Identifying Issues within PowerApps

The first, and arguably the most important task when troubleshooting a PowerApps issue is identifying where the source of an error is within your app. 

In this section, we will provide you with guidance on three ways to identify errors in your apps.

Look for Error and Warning Icons

When you are building apps, you often come across some signs that mean that something is going wrong in the app. Two such sign/icons are a Red cross and Yellow Triangle.

  • Red Xs represent errors that have occurred

  • Yellow triangles are indications of warnings

In the rest of this article, we will discuss the meaning and impact of these two error signs in detail.

1.png

Expression Editor

When you come across a Red x or a Yellow triangle, you can click on the error to see an option that says ‘Edit in the formula bar’. Clicking on this option will take you directly to the offending expression in the formula bar.
You have to click in the formula bar to see the error highlighted. Unless you click in the formula bar, the error is not highlighted. This helps identify the issues within your apps. 

1b.png

The Stethoscope

This is a very important place to find issues within your app. You can find the stethoscope icon in the upper-right corner of the PowerApps designer. When you click on it, you will see a list of all the errors within your app.

Errors are organised under categories like Formula, Accessibility, Runtime and Rules. You can click on those categories to expand them and get more details about the errors and warnings that exist in the app.

1c.png

Step 2: Inspect

Gathering Specific Details about the Errors in your App

Once you have identified the errors that exist in your app, it’s time to begin inspecting them. The last section shows us where the error was happening within the app - this section will help us gather more information about the error.

UI Clues / The Mouseover

You can follow the dots (figuratively) within the UI of the app to inspect the app’s errors.

For example, as soon as you put the cursor over one of the errors or warning icons, you will see more details about the error/warning. It’s a great way of getting more information about the error.

Similarly, if you click on the error, you get a context menu, where you can click on ‘Edit in the formula bar’ to jump into the expression editor. In the expression editor, you can right away see if there are more errors. You can hover your cursor over the formula and see more details about the error there.

2a.png

Errors and Warnings

Errors often break your app. If you have an error within the app, some functionality might not work right.

For example, if you have a typo in a property in gallery control, you can fix it in the expression editor, and once you fix the problem, you can see in real time that the related fields in the app are not broken anymore and show values as they are supposed to.

Like errors, even warnings cause issues with the functionality of your app or the in data that you’re working with.  For example, in the given screenshot, we are warned about a delegation error, which may effect how the app will function. 

You can read more articles about Delegation error in the product documentation by clicking here.

2b.png

The Stethoscope

The stethoscope, besides helping in error identification, is also very helpful in investigation of errors.

As discussed earlier, when you click on the stethoscope icon, you see that everything is organized in the App Checker by Formula, Runtime, Rules and Accessibility. You can click on any of these categories and get more details about the app, specifically on Errors and Warning in the app.

More importantly, when you can click on error and warning details, it brings on more specific information about that particular error/warning. In this manner, you can navigate through all the errors and warnings within the app, using the stethoscope. 

When you click on a warning, the Expression editor is automatically updated and you are directed into that specific warning and its details, so that you can inspect and correct it.

2c.png

Variables and Collections

One important way to inspect the data in your app is to have a look at the collections and variables in your apps.

Click on the View button in the top menu. Click on Collections from the navigation that opens to reveal the collections you are working with. 

In the given example, we have used a Camera Photo collection with its respective schema. If there were some data in this app, that would have reflected in the collection. These collections show what our data actually looks like. 

Similarly, you can click on Variables (after clicking on View on top) to see all the Variables and the data they are currently holding.

This helps in inspecting and troubleshooting any error that exists in you app’s your data.

2d.png

Formula Bar Results View

To get a quick preview of your data to inspect issues, you can use the Formula Bar results view.

The Formula Bar Results view needs to be activated within the Setttings for your PowerApp. Click on File, App Settings, and Advanced settings. Scroll down to Experimental features. Here you will see ‘Enable Formula bar results view.’ Activate it.

This feature makes your formula bar more powerful. Now, if you click in the formula bar and click on a collection reflecting there (in the given screenshot, it’s data coming out of SharePoint), you can just click on the collection to see a preview of the data in the collection.
It’s a quick and easy way to see what’s happening with the data within your app. You do not have to navigate around to locate errors, if you use this quick method.

Levels of Underlining

Errors in the expressions bar are underlined in different colors. There are different levels of underliningRed, Blue, and Double Underlining (watch carefully for this) — each of these indicate different issues within your expression.

  • Blue underlining depicts a Warning

  • Red underlining depicts an Error

For example, in the given screenshot, when we go to the Gallery, and click inside the formula bar, we see a blue error (which means it is a Warning, as it has a blue underlining). 

2f.png

To this, if you add another property that’s incorrect, we will see a red underlining on the formula, depicting an additional issue within our expression.

When we look closely, we see Double underlinings at two places—one place has Double (Red & Blue) and another place has Double Red—that means that there are multiple errors and warnings in the expression.

Only a close inspection of an expression reveals double errors which are often overlooked.

2f2.png

Step 3: Resolve

Solving Expression Issues

They say experience is the best teacher - in this case, we definitely agree. Building and fixing issues is a great way to learn.

Hopefully the ideas in this section will improve your ability to resolve PowerApps expression issues.

Using Labels to Help Troubleshoot

Here is a method that helps you check your values quickly.

Using this method, you can use a label’s text property to expose the outputs of your expression (in a text format) to see if formulas are working as expected.

If you’re working on inspecting an error in an expression and you’re trying to figure out what its issue might be:

  • Put a label on the canvas

  • Set the formula you are inspecting as the label’s text property

If the expression breaks, you can quickly interact with the expression to correct it. Using the label In this manner, provides you with an interactive troubleshooting mechanism.

3a.png

Breaking Down Complex Expressions

Breaking down functions helps solve expressions step-by-step.

We recommend reducing the number of functions in a problematic complex call with nested expressions. Start from the outside in, by removing functions to isolate the break point.

The idea here is to break expressions into the smallest parts possible, then build them up again. 

This method helps isolate specific problem areas in an expression and can reduce the time spent troubleshooting.

3b.png

Did your Expression Run?

Throughout an app, various events fire or are triggered that may be responsible for the execution of your expression.

We can manually check such events and correct any issues that exist with them.

A simple example of this is the Button’s OnSelect event. This is an easy one to troubleshoot. Not all event’s are this straightforward though.

The App’s OnStart Event

The App’s OnStart event run’s when the app is opened. If you are in the Canvas App Designer, this is also true. If you modify the App’s OnStart expression(s), you need to re-run them.

You can open and close the app…

or

Use the handy “Run OnStart” event exposed by Right Clicking on the top node of the tree view.

3c.png

Homework: Know your Functions

To build an error-free app, it’s important to know your functions. You can refer to the PowerApps function reference page to find the right functions.

The PowerApps function reference is a great resource when you’re working with expressions. 

It’s freely available for everyone to look at - you’ll find full documentation on all of the functions.

Format Text / Remove Formatting

To change the way your function is arranged - you can choose to Format Text or Remove Formatting

Try both of these methods - each has an affect on the readability of your function and may reveal more details on where your expression is broken.

3e.png

Conclusion

We regularly use the above tools and methods to identify, inspect and resolve errors in our PowerApps. 

Good Luck!

If you’d like to watch a video walk through of these techniques, check out our video on YouTube.