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 / IfError() not working ...
Power Apps
Answered

IfError() not working in Canvas Apps with ClearCollect() and Set() functions

(0) ShareShare
ReportReport
Posted on by 38

I'm trying to use IfError() function to figure out its functionality. I have a simple example where I use ClearCollect() as below (in a onSelect() of a button). Not sure what I'm doing wrong but only the first ClearCollect() executes and the collection colTempS4_1 has data, and the collection colTempS4_2 remains empty.

 

After the code execution:

colTempS4_1 has correct data,

colTempS4_2 has correct data,

colTempS4_3 remains empty,

varTempS4_4 remains empty,

varTempS4_5 remains empty,

varTempS4_6 has correct data,

varTempS4_7 has correct data

 

(The collections have not been used elsewhere in the app. Formula-level Error Management was also on in the app.)

 

With({K:0},

    With({K1:ForAll(Sequence(10) As I,K+I.Value),K2:ForAll(Sequence(10) As I,K+1+I.Value)},

        IfError(

            ClearCollect(colTempS4_1,K1),Notify("Error-1",Warning,1000);false,

            ClearCollect(colTempS4_2,colTempS4_1),Notify("Error-2",Warning,1000);false,

            ClearCollect(colTempS4_3,K2),Notify("Error-3",Warning,1000);false,

            Set(varTempS4_4,K1),false,

            Set(varTempS4_5,K2),false,

            true

        );

        Set(varTempS4_6,K1);

        Set(varTempS4_7,K2)

    )

)

 

When I check the app monitor, the diagnostic shows that the third ClearCollect() executed and collected 1 row. Either way, all the collections/variables should have contained the same number of rows, and none should remain empty

2023-01-12_06-38-13.jpg
Categories:
I have the same question (0)
  • Verified answer
    iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Hey @shdfbasfgagfkay 

     

    I used your code in a new app exactly as you have it and all of the collections and variables were populated - see gif below.

     

    IfErrorTest.gif

     

    Are you setting the same values anywhere else?

    Maybe there's a type mismatch with other places that's resulting in an empty collection/variable.

     

    Cheers,

    Sancho

  • shdfbasfgagfkay Profile Picture
    38 on at

    Hi @iAm_ManCat,

     

    Thanks for testing it. Today, I rechecked that code in the app, I haven't modified anything, and see noticed it working fine. (BTW - I did not have the same collections/variables duplicated anywhere else in the app.) The only thing I can think of is that when I edited the app recently to test other stuff, it must have updated the Power Apps version and Microsoft may have fixed the issue.

    I have had lots of problems in other app I was developing due to the IfError() and had to remove it entirely. Still, I'll be using it with grain of salt but at least this particular test is working.

    Thanks again.

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    No worries, as long as it works now right!

    And yes there's still some bugs on their side that need ironing out, so its always good to check your code to see that it works (even when you know it should 😂 )

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 846

#2
Valantis Profile Picture

Valantis 532

#3
Haque Profile Picture

Haque 410

Last 30 days Overall leaderboard