Showing results for 
Search instead for 
Did you mean: 
Advocate II
Advocate II

Return value of Collect Statement

It seems like a very simple question, but how do you handle return values of f.e. COLLECT statements.

In my case I simply want to save a collection into another collection and if this works fine, then another collection shall be cleared!


Clear shall only be processed, if the first statement (COLLECT) is true or something ...


How would you do it?


Collect('[dbo].[Bestellung]';ToDB);; Clear(Einkaufskorb)




Community Champion
Community Champion

This seems to work:

Collect(ResultCollection, Collect('[dbo].[Bestellung]', ToDB))

Please note that you should use ; instead of , if you are in a European locale

Power Apps
Power Apps

You can use the Errors function, that will return a collection with the errors from the last interaction with the data source. For example, in your case you could use the following expression:

Collect('[dbo].[Bestellung]'; ToDB);;
If(CountRows(Errors('[dbo].[Bestellung]')) = 0); Clear(Einkaufskorb))

Hi @CarlosFigueira

The Errors function would be great, but I have found it not always works as expected with Azure SQL / SQL Server.

Also, it is always more robust to have positive confirmation of a result (via return value) rather than negative return in case of error.

This is doubly true given the bugginess of the PowerApps to Azure SQL / SQL Server connector.

@Meneghino Good to know; I've used the Errors in an internal app and haven't had any problems yet, but it's used by a handful of people. If in the future you have a specific instance of the Errors function misbehaving, could you send us the session id for it? Thank you!

Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group


Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (46,998)