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 / Error Collection follo...
Power Apps
Unanswered

Error Collection following Patch

(0) ShareShare
ReportReport
Posted on by 546 Super User 2024 Season 1

I'm trying to collect any errors that happen following a Patch command.  Here is my code:

If(IsEmpty(Errors(Projects)),
 Notify("Update successful!",NotificationType.Success,2000),
 Collect(colErrors,Errors(Projects));
 Notify("Update failed!",NotificationType.Error,2000)
)

Everything seems to be working fine with this (no squiggly lines) for 3/4 lists that I'm patching.  Each time I used the code, I just copied & pasted it and changed the name of the list that is being patched & checked.  

 

For some reason, 1 of the 4 lists that I'm updating & checking gives me a red squiggly line right away, saying:

The function 'Collect' has some invalid arguments.

Incompatible type.  The collection can't contain values of this type.

If I change the name of the collection to colErrorsT, no problem, squiggly lines disappear.

 

So I figured that maybe it's not the same schema for the 2 collections, but it is: 

zuurg_0-1663195142598.pngzuurg_1-1663195192645.png

Any idea why it's having an issue with just the error collection for just that 1 list?  I can't see any collection contents because I can't trigger an error.  

Categories:
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @zuurg 

    I recommend to call Errors only once, so i would recommend reducing the repetition of Errors(Projects) using With like below:

     

     

    With
    ( 
     {errorsInProjects:Errors(Projects)},
     If(IsEmpty(errorsInProjects),
     Notify("Update successful!",NotificationType.Success,2000),
     Collect(colErrors,errorsInProjects);
     Notify("Update failed!",NotificationType.Error,2000)
     )
    )

     

     

    I do not know for sure this will end up helping with the issue you are having.

    In case it does help with the issue, let me know.

    If the above does not work, try the below, see if it helps:

     

     

    Clear(colErrors);
    With
    ( 
     {errorsInProjects:Errors(Projects)},
     If(IsEmpty(errorsInProjects),
     Notify("Update successful!",NotificationType.Success,2000),
     Collect(colErrors,errorsInProjects);
     Notify("Update failed!",NotificationType.Error,2000)
     )
    )

     

     

    Try adding 

     

    Clear(colErrors);

     

    before using the Collect. You can also put it closer to where it's about to be used if you prefer, like this:

     

     

    With
    ( 
     {errorsInProjects:Errors(Projects)},
     If(IsEmpty(errorsInProjects),
     Notify("Update successful!",NotificationType.Success,2000),
     Clear(colErrors);
     Collect(colErrors,errorsInProjects);
     Notify("Update failed!",NotificationType.Error,2000)
     )
    )

     

     

    Or even just use ClearCollect instead, like this:

    With
    ( 
     {errorsInProjects:Errors(Projects)},
     If(IsEmpty(errorsInProjects),
     Notify("Update successful!",NotificationType.Success,2000),
     ClearCollect(colErrors,errorsInProjects);
     Notify("Update failed!",NotificationType.Error,2000)
     )
    )​

     

    See if it helps @zuurg 

  • zuurg Profile Picture
    546 Super User 2024 Season 1 on at

    @poweractivate ,

    The reason I'm calling Errors more than once is because in this one .OnSelect property (for a Save icon), I'm having to write to 4 different Sharepoint Lists, so after each patch, I'm checking for errors from that patch.  Like I said in the post, there is no issue with the collect for 3/4 of the lists, there is just 1 that is causing the squiggly lines for reasons unknown.

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @zuurg 
    OK, so let's say you leave the formula like that without any change:

     

    If(IsEmpty(Errors(Projects)),
     Notify("Update successful!",NotificationType.Success,2000),
     Collect(colErrors,Errors(Projects));
     Notify("Update failed!",NotificationType.Error,2000)
    )

     

     

    Does putting, at the very top before the If, either

     

    Clear(colErrors);

     

    or

     

    ClearCollect(colErrors,Blank());​

     

     

    help?

     

     

    //Does putting either 
    //Clear(colErrors);
    //or
    //ClearCollect(colErrors,Blank());
    //make the error go away?
    If(IsEmpty(Errors(Projects)),
     Notify("Update successful!",NotificationType.Success,2000),
     Collect(colErrors,Errors(Projects));
     Notify("Update failed!",NotificationType.Error,2000)
    )

     

     

    If not, (or if for some reason, you do not want to clear the Collection at all in this part of the formula),

    could you provide an example of some mock data for the 3 that do work, and the 1 that does not work?

  • zuurg Profile Picture
    546 Super User 2024 Season 1 on at

    So I guess that when I posted this yesterday, I was under the impression that since the schema for the colErrors and colErrorsT appeared to match, that re-using the same collection for patches to different lists was allowed (since it worked for 3/4 of them and only 1 was giving me problems.  

     

    Went back in the code just now to try to mess with it again, and saw that there were now more errors for those other 2 list error collections that weren't showing up yesterday.  

     

    Giving all 4 Patch Error collections different names (1 for each list I'm patching) seems to have fixed the problem across the board.  Again, seems odd since looking at the schema for all 4 collections, they all look the same to me, but the more I use Power Apps, the more I realize it can be a bit quirky sometimes.

     

    Since I've never triggered an error in patching, what would be a good way to include the contents of one of the collections in an email or Errorlog list?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 320

#3
Mohsin Ali Profile Picture

Mohsin Ali 246

Last 30 days Overall leaderboard