Showing results for 
Search instead for 
Did you mean: 
Power Apps
Power Apps

3.22022: changes in the [Clear]Collect function with error arguments

Summary: Starting in version 3.22022 of Power Apps Studio, if one of the arguments to to the [Clear]Collect function is an error, then the [Clear]Collect expression will return an error - meaning that something like an expression like the one below can now be used to catch errors from data sources:

IfError(Collect(myCache, DataSource), Notify("Error loading data!"))

This only applies to apps with the 'Formula-level error management' feature enabled.


More details: following some feedback from the community, we changed how the [Clear]Collect function behaves if one of its arguments is an error. Take the example below (assuming that the schema for DataSource[1-3] are equivalent), in the OnSelect property of a button:

    LookUp(DataSource1, Condition1),
    LookUp(DataSource2, Condition2),
    LookUp(DataSource3, Condition3))

If a user clicked the button, and one of the data sources was unavailable (for example, the table had been removed - which would make the LookUp call return an error), the error would be inserted into the collection itself, and as it was "handled", it would not be shown to the user. Another more common scenario, where the app wants to cache a data source into a local collection:


To be consistent with the first example, this would also not return an error, and myCache would have an error as its element. This made checking errors in those expressions harder (as seen in this thread) - we would need to check the records inside the collection.

Starting in version 3.22022, those expressions will return errors, and they can be handled directly by using the IfError function:

    ClearCollect(myCache, DataSource1),
    Notify("Error reading data from DataSource1!"))

We can also directly access the errors that were returned, and trace them out to get more information:

    ClearCollect(myCache, DataSource1),
    Trace("Error loading data source", TraceSeverity.Critical, { errors: AllErrors });
      Notify("Error reading data from DataSource1!"))

Hopefully this helps understanding this recent change. As usual, we want your feedback (and we're making changes based on it)! Let us know if you have any questions, concerns, suggestions or bug reports on the error handling feature.


Helpful resources

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.


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 (3,831)