Summary: Starting in version 3.22041 of Power Apps Studio (which should start rolling out to the Preview region in the week of April 4th), if the result of one of the expressions in the ForAll function is an error, then the ForAll 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(
ForAll(
myCache As c,
Patch(MyDataSource, Id = c.Id, { Value: c.Value })),
Notify(
"Error patching data from the collection! Total of " &
CountRows(AllErrors) &
" errors."))
This only applies to apps with the 'Formula-level error management' feature enabled.
More details: following some feedback from the community, we had previously changed other functions that used to return collections with nested errors (such as [Clear]Collect, see this post for more details). On versions prior to 3.22041, the ForAll function would always return a valid collection, but if any of the expressions returned an error, that error would be stored in the collection itself - making it harder to make sense of its errors. Starting on version 3.22041, the ForAll function now has a similar behavior to [Clear]Collect: it will return the error(s) from the expression evaluations. That allows for apps to handle these errors and notify the users directly:
IfError(
ForAll(myLocalCache, Collect(myDataSource, ThisRecord)),
Notify("Errors adding data to the data source!"))
Or tracing detailed information about the errors:
IfError(
ForAll(myLocalCache, Collect(myDataSource, ThisRecord)),
Trace("Error flushing local cache", TraceSeverity.Error, { errors: AllErrors });
Notify("Errors adding data to the data source"))
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.

Report
All responses (
Answers (