web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / 3.22022: changes in th...
Power Apps
Unanswered

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

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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:

Collect(
 myCollection,
 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:

ClearCollect(
 myCache,
 DataSource1)

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:

IfError(
 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:

IfError(
 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.

Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 101 Most Valuable Professional

#2
Haque Profile Picture

Haque 81

#3
VASANTH KUMAR BALMADI Profile Picture

VASANTH KUMAR BALMADI 70

Last 30 days Overall leaderboard