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 / Forall() works fine un...
Power Apps
Answered

Forall() works fine until i close and reopen the app

(0) ShareShare
ReportReport
Posted on by 39

Hi,

As the title suggests Im using a forall() function that iterates over records in a filtered Collection1, and patches output to Collection2...  It all works fine and as it should but when I close the app and re-open, the app throws up many errors relating to Collection2 saying "invalid argument type(Error) Expecting a table value instead" - CountRows(Collection2). 

 

If I delete the forall() function and re-insert the errors go away and all is good again, until the next time the app is opened again.

 

Any ideas/ assistance would be hugely helpful

Categories:
  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Aki78 what's in collection 2 at app start 

  • Aki78 Profile Picture
    39 on at

    Just pulling in the Column names no records as yet

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Aki78 try having 1 record at App Start to see if that clears the errors. 

  • Aki78 Profile Picture
    39 on at

    Ok, just tried that...  but still errors, Is it possible PA is getting confused and perhaps i should use the record currently being iterated over in the ForAll() 'As TheRecord' and then reference the column value as 'TheRecord.thecolumnval'

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Aki78 you could try that. Meanwhile can you share some code to see what you're collecting into collection 2 and where you are using it. 

  • Aki78 Profile Picture
    39 on at

    Still no cigar with the addition of the 'As', ive included a doc with code snips

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Aki78 Oh boy! That's a lot of code.

    May I ask you why you are using instead of Submit Form. Then you can use LastSubmit(). ID to get the ID back rather than having to do another collect. 

  • Aki78 Profile Picture
    39 on at

    @CNT Using a form isnt practical in my scenario, I started off with one form and soon realised that I needed multiple forms and galleries to achieve the functionality needed...   Alot of code in the app, biggest code block has 1400 lines of code - yikes! 

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Aki78 so what are the errors that you get and in which controls? 

  • Aki78 Profile Picture
    39 on at

    Any call to Collection2 flags an error as incorrect argument type be it a LookUp a patch or a collection - Its as if Powerapps thinks there is a datastructure inconsistency, and when I remove the code block and paste it back in it realises there is no issues. 

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 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard