Formula-level error management

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

Table of Contents

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:

ErrorKindDescription
ErrorKind.ConflictAnother 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.ConstraintViolationOne or more constraints have been violated.
ErrorKind.CreatePermissionAn attempt was made to create a record, and the current user doesn’t have permission to create records.
ErrorKind.DeletePermissionAn attempt was made to delete a record, and the current user doesn’t have permission to delete records.
ErrorKind.EditPermissionAn attempt was made to edit a record, and the current user doesn’t have permission to edit records.
ErrorKind.GeneratedValueAn attempt was made to change a column that the data source generates automatically.
ErrorKind.MissingRequiredThe value for a required column is missing from the record.
ErrorKind.NoneThere is no error.
ErrorKind.NotFoundAn attempt was made to edit or delete a record, but the record couldn’t be found. Another user may have changed the record.
ErrorKind.ReadOnlyValueAn attempt was made to change a column that’s read only.
ErrorKind.SyncAn error was reported by the data source. Check the Message column for more information.
ErrorKind.UnknownThere was an error, but of an unknown kind.
ErrorKind.ValidationThere was a general validation issue detected, that did not fit one of the other kinds.

Leave a Reply

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

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 4,912 other subscribers

Recent Posts

Archive

Thank you for visiting SharePains

%d bloggers like this: