cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fuku-Shima
Helper I
Helper I

The value stored in FirstError / AllErrors is not the latest value, is this a specification?

The error information stored in FirstError is not the last error that occurred, but the last error at the time OnError was triggered. Is this a specification? Is it a bug?

 

I'm checking the behavior of OnError and FirstError / AllErrors when multiple OnError are executed simultaneously.

The following methods are used to check.

  • The following procedure is written in OnError.

(1) Store the contents of FirstError at this point in a variable.
 Set(AppCatchedErr,FirstError);
(2) Insert the following contents at this point into the collection (ErrorCollection)
 AppCatchedErr,FirstError,First(AllErrors)
(3) Time-consuming process. (This is intended to create a time difference between (2) and (4).
  This is achieved by Refresh() on multiple tables
(4) Insert the following contents at this point into the collection (ErrorCollection)
 AppCatchedErr,FirstError,First(AllErrors)

  • A button to retrieve the collection from the data source has been placed.
     OnSelect =ClearCollect(collectionA,SharePointListA);
  • Five labels are placed that do not handle errors.
     Text = CountRows(collectionA)
  • Next, I ran the application offline and generated a network error.

 

This should cause OnError to be executed five times when the button is pressed.The results are as follows

  • The order of the -ErrorCollection was such that the records inserted in the processing of each OnError (2) were lined up after the records inserted in the processing of each OnError (4).
  • The value of AppCatchedErr stored the last error content. For example, the contents of AppCatchedErr collceted in (4) were the information of the error that occurred from the fifth label in all five cases. (observed = "5thLabel.Text")
  • The contents of FirstError and First(AllErrors) were always information about the error that triggered OnError.
    For example, in an OnError triggered on the first label, the contents of AppCatchedErr collected in (4) are the errors that triggered the last OnError (observed = "5thLabel.Text"), but the contents of FirstError collected at this time are the errors that triggered the first The error information for the first label (observed = "1stLabel.Text").

 

 

These indicate the following behavior at this time.

  • OnError is executed asynchronously and in parallel.
  • If a variable is updated during an OnError, the change is shared by other OnErrors.
  • The values stored in FirstError and First(AllErrors) are not the contents of the latest error, but the last error at the time OnError was triggered. Therefore, even if multiple OnErrors are triggered simultaneously, the value indicated by FirstError in each OnError process is the content of the error that triggered that OnError.

 

Is this a specification?
Or is it a bug where the FirstError / AllErrors value is fixed within the OnError process?

Since it is quite common for an OnError to be triggered multiple times from a single action, I am concerned that if this is a bug rather than a specification, OnError will not have the effect I am hoping for.

The version is 3.22021.27.
The following article is a reference, but I could not confirm about the actual specification.

3.21122: Filter behavior change with errors - Power Platform Community (microsoft.com)

IfError, IsError, and IsBlankOrError functions in Power Apps - Power Apps | Microsoft Docs

 

Thank you in advance for your answer.

 

PS

This posting is made using DeepL.
If there is something wrong with my grammar that you don't understand, I would appreciate a reply.

 

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

Hello @Fuku-Shima thank you for your post. You are correct, the specification of App.OnError is that it will be triggered for all instances of errors that are not handled - not for an action that may have caused that error - and it can happen concurrently. If you store the error in a variable, and try to access it later in the same App.OnError expression, it is possible that other instances of App.OnError would have overwritten it.

 

  • If you want to, anywhere in the App.OnError expression, access the error that triggered it, you can refer to FirstError (or AllErrors).
    • You can also have something like With({fe: FirstError}, <the expression that references 'fe'>) if you want to save the FirstError in a "local" variable that is only visible for that instance of the App.OnError call.
  • If you want to, anywhere in the App.OnError expression, access the latest error that happened in the app, you can do something like you are doing today: storing it in a global variable, with the last one overriding the previous ones on that variable.

 

Hope this helps. If not, can you provide more details of your scenario?

View solution in original post

2 REPLIES 2
CarlosFigueira
Power Apps
Power Apps

Hello @Fuku-Shima thank you for your post. You are correct, the specification of App.OnError is that it will be triggered for all instances of errors that are not handled - not for an action that may have caused that error - and it can happen concurrently. If you store the error in a variable, and try to access it later in the same App.OnError expression, it is possible that other instances of App.OnError would have overwritten it.

 

  • If you want to, anywhere in the App.OnError expression, access the error that triggered it, you can refer to FirstError (or AllErrors).
    • You can also have something like With({fe: FirstError}, <the expression that references 'fe'>) if you want to save the FirstError in a "local" variable that is only visible for that instance of the App.OnError call.
  • If you want to, anywhere in the App.OnError expression, access the latest error that happened in the app, you can do something like you are doing today: storing it in a global variable, with the last one overriding the previous ones on that variable.

 

Hope this helps. If not, can you provide more details of your scenario?

Hello CarlosFigueira . Thanks for the reply.


I am relieved to know that it is not a bug but a specification.
The spec is exactly what I would expect regarding FirstError within OnError.

Resolved. Thank you .

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Kudoed Authors
Users online (2,959)