Errors function

Applies to: Canvas apps Model-driven apps

Provides error information for previous changes to a data source.


Errors can happen when a record of a data source is changed. Many causes are possible, including network outages, inadequate permissions, and edit conflicts.

The functions that modify data in data sources, such as Patch, Collect, Remove, RemoveIf, Update, UpdateIf, and SubmitForm report errors in two ways:

  • Each of these functions will return an error value as the result of the operation. Errors can be detected with IsError and replaced or suppressed with IfError and App.OnError as usual. See Error Handling for more information.
  • After the operation, the Errors function will also return the errors for previous operations. This can be useful for displaying the error message on a form screen without needing to capture the error in a state variable.

You can avoid some errors before they happen by using the Validate and DataSourceInfo functions. See working with data sources for more suggestions on how to work with and avoid errors.


The Errors function returns a table of errors that contains the following columns:

  • Record. The record in the data source that had the error. If the error occurred during the creation of a record, this column will be blank.
  • Column. The column that caused the error, if the error can be attributed to a single column. If not, this will be blank.
  • Message. A description of the error. This error string can be displayed for the end user. Be aware that this message may be generated by the data source and could be long and contain raw column names that may not have any meaning to the user.
  • Error. An error code that can be used in formulas to help resolve the error:
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.

Errors can be returned for the entire data source, or for only a selected row by providing the Record argument to the function.

Patch or another data function may return a blank value if, for example, a record couldn't be created. You can pass blank to Errors, and it will return appropriate error information in these cases. Subsequent use of data functions on the same data source will clear this error information.

If there are no errors, the table that Errors returns will be empty and can be tested with the IsEmpty function.


Errors( DataSource [, Record ] )

  • DataSource – Required. The data source for which you want to return errors.
  • Record – Optional. A specific record for which you want to return errors. If you don't specify this argument, the function returns errors for the entire data source.


Step by Step

For this example, we'll be working with the IceCream data source:

Ice Cream.

Through the app, a user loads the Chocolate record into a data-entry form and then changes the value of Quantity to 90. The record to be worked with is placed in the context variable EditRecord:

  • UpdateContext( { EditRecord: LookUp( IceCream, Flavor = "Chocolate" ) } )

To make this change in the data source, the Patch function is used:

  • Patch( IceCream, EditRecord, Gallery.Updates )

where Gallery.Updates evaluates to { Quantity: 90 }, since only the Quantity property has been modified.

Unfortunately, just before the Patch function was invoked, somebody else modifies the Quantity for Chocolate to 80. Power Apps will detect this and not allow the conflicting change to occur. You can check for this situation with the formula:

  • IsEmpty( Errors( IceCream, EditRecord ) )

which returns false, because the Errors function returned the following table:

Record Column Message Error
{ Flavor: "Chocolate", Quantity: 100 } blank "Another user has modified the record that you're trying to modify. Please reload the record and try again." ErrorKind.Conflict

You can place a label on the form to show this error to the user.

  • To show the error, set the label's Text property to this formula:
    Label.Text = First(Errors( IceCream, EditRecord )).Message

You can also add a Reload button on the form, so that the user can efficiently resolve the conflict.

  • To show the button only when a conflict has occurred, set the button's Visible property to this formula:
    !IsEmpty( Lookup( Errors( IceCream, EditRecord ), Error = ErrorKind.Conflict ) )
  • To revert the change which the user selects the button, set its OnSelect property to this formula:
    ReloadButton.OnSelect = Revert( IceCream, EditRecord )