PowerApps – Experiment with error handling

Within PowerApps there is an experimental feature that could be quite useful. Time to experiment with these features.

Note that you shouldn’t use this in a production app unless you don’t mind being disturbed while you are on holiday.

Formula-level error management

Formula-level error management is one of the experimental features that could become useful. Ok, some adjustments might be needed to improve this feature, but at least it shows us a start of what might come one day.

I found that once I enabled the feature I got the following options appear:

  1. IfError
  2. Errors

IfError

IfError is a function that can help you catch problems with functions that you may run. Below you can see an example of the use of the IfError function. When the conversion of the textfield TextInput2 is failing the number -1 is returned. This could happen if the TexInput doesn’t contain a number but some text.

IfError function used in Power Apps

Note that the IfError function can only return values of a single type. This means that if you used the following to convert “test” into a date then you would need the fallback value to be set to a valid date.

IfError(DateValue(“test”),”01/01/2019″)

Errors

The Errors function returns an array of errors returned by datasource. In my example below I’ve got a form connected to my testlist in SharePoint. If you want to go further you could even specify which record you want to see the errors for.

I first created my list, then I created my form and then I adjusted the type of the field in SharePoint. I changed one of my text fields into a number field. This then resulted in an error added to the collection of Errors.

Errors array in Power Apps

In my screen above I’m getting the error code of 8. This number actually represents an error kind. All the kinds of errors that are handled are listed below:

ErrorKind Description
ErrorKind.Conflict Another change was made to the same record, resulting in a change conflict. Use the Refresh function to reload the record and try the change again.
ErrorKind.ConstraintViolation One or more constraints have been violated.
ErrorKind.CreatePermission An attempt was made to create a record, and the current user doesn’t have permission to create records.
ErrorKind.DeletePermission An attempt was made to delete a record, and the current user doesn’t have permission to delete records.
ErrorKind.EditPermission An attempt was made to edit a record, and the current user doesn’t have permission to edit records.
ErrorKind.GeneratedValue An attempt was made to change a column that the data source generates automatically.
ErrorKind.MissingRequired The value for a required column is missing from the record.
ErrorKind.None There is no error.
ErrorKind.NotFound An attempt was made to edit or delete a record, but the record couldn’t be found. Another user may have changed the record.
ErrorKind.ReadOnlyValue An attempt was made to change a column that’s read only.
ErrorKind.Sync An error was reported by the data source. Check the Message column for more information.
ErrorKind.Unknown There was an error, but of an unknown kind.
ErrorKind.Validation There was a general validation issue detected, that did not fit one of the other kinds.

Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Avatar of Pieter Veenstra

Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like. I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide. For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions. SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/ Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/ You can contact me using contact@sharepains.com

Related Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains

Subscribe now to keep reading and get access to the full archive.

Continue reading