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 / Patch with collection ...
Power Apps
Answered

Patch with collection resulting in nulls

(0) ShareShare
ReportReport
Posted on by 24

I am working on a checklist app.  There are 80 different checklist items. This checklist can be repeated multiple times per day, and I want to capture each occurrence of the completion of the checklist.  When the checklist is completed, I want to add a new record for each checklist item. I'll call the table that holds all the checklist results table B.

 

I have one table that has 80 rows in it (table A). In this table are two varchar columns that contain information about the thing that is being checked or not. I have created a gallery from this table. In the gallery, I have added three toggles and a Text field. My goal is to allow a user to change those controls, and when clicking submit, the values from those controls and the associated records from table A end up being written to table B.

 

Here it is:

 
 

QC Checklist - Saved (Unpublished) - Power Apps - .png

 

I am running a ForAll(gallery.AllItems, Collect(collection_checklist, {.....})) to build a collection.

I then run Patch(table_b, collection_checklist)

 

What ends up happening is that it writes nulls to some of the new rows in table b where I know it should not be null. I have even built a new gallery from the collection that's created to make sure it does not have null values. 

 

Static values or values from table A, which is the data source for the gallery, that get written to the collection all make it to table B.  Many, but not all, of the values from the controls I added to the gallery do not make it into table B. If any of those columns are null in the sql table, they are all null in that same record, regardless of how they appear in the app. It seems to be able to pass the first 15-20, and after that it just loses it and they all go null. 

 

Since some work and some don't, I assume that either it just can't handle this many records, or perhaps I am not building this optimally. Any ideas or suggestions would be greatly appreciated. 

 

 

Categories:
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @destro :

    Could you tell me:

    • Whether the data in collection_checklist is complete?

    I think that although Patch(table_b, collection_checklist) can also work, but it is not the correct syntax. Maybe you could try:

    ForAll(gallery.AllItems, Patch(table_b,Defaults(table_b), {.....}))

    Best Regards,

    Bof

  • destro Profile Picture
    24 on at

    The collection is complete. It contains all 80 records. When it writes to the database, it also creates all 80 records; it’s just that some of the columns go null. The method I am using works fine if I’m just sending a few records. When I sent all 80, it doesn’t like it. 

    I did use the ForAll(gallery.AllItems, patch(...)) originally, but it ran pretty slowly, so I was trying this other method to see if I could get any performance gains. I’m also concerned about the number of API calls. I was testing doing it with the collection to see if I could write all the data with a single API call, but I’m thinking that’s not how it works. 

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @destro :

    Maybe you could try:

    Collect(
    table_b,
    ForAll(gallery.AllItems,{.....})
    )

    Best Regards,

    Bof 

  • Verified answer
    destro Profile Picture
    24 on at

    I made a mistake in what I said I was doing above. I’ll blame late night and exhaustion. I was using collect() as you suggested, not patch(). 

    What I ultimately did that resolved the issue was to just add the columns in table A and populate them with dummy values. Then when it does the collection, it finds my updates. What I was originally doing was just adding controls into the gallery and storing those values into the collection. I found that bringing those controls in as representations of values in table A causes the collection to find them. 

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @destro :

    Thanks for your feedback.

    Glad to hear that you have solved this issue.

    Best Regards,

    Bof

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard