PowerApps – Experimenting with error handling

Within PowerApps there is an experimental feature that could be quite useful. 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.

Note that the IfError function can only return values of a single type. Thsi 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

 

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.

 

 

 

Advertisements

Please leave a comment or feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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