cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mike528
Resolver II
Resolver II

Patch Collection not Updating Blank Columns

I am working on an offline scenario in an app to be run from a tablet.  If connected, I load a collection of rows that can be updated offline and then synched to the DB once back online. 

 

I create a collection as;

ClearCollect(colMembers, Filter('[dbo].[Members], IsActive = true))

 

then when one of the rows is selected for edit, I update controls on a screen with their current value to be edited. When saving (clicking the save button) I issue a patch command.

 

Patch(colMembers, First(Filter(colMembers, MemberId = varSelectedMemberId)), {FirstName: txtFirstName.Text, LastModified: Now()})

 

I've paired this down for clarity, but the FirstName updates fine, but LastModified will only update if it previously had a value. I find this quite odd as I don't have this issue patching Azure DB tables directly, only a local in-memory collection. I checked other columns and all will update if they previously had a value, any rows where a column is blank, simply refuses to update. I have to keep all changes in this collection, that saves to local device data store using SaveData() so that I can synched once back online.

 

I would consider this a bug. Has anyone else run across this?  

 

I saw somewhere that UpdateIf might work, while it's a workaround, this is still not right.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@mike528 

Yes, this is a long standing bug with the Patch function with blank columns and collections.

Use the UpdateIf function.  It works 100% of the time.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

9 REPLIES 9
RandyHayes
Super User
Super User

@mike528 

Yes, this is a long standing bug with the Patch function with blank columns and collections.

Use the UpdateIf function.  It works 100% of the time.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

That's interesting. Do you know if this is only related to Azure DBs or does it also affect SharePoint Lists? 

 

Reason I ask is because I have almost this exact same build design going on as @mike528 (thought he may have hacked my Environment for a moment, lol) except I'm using SharePoint so wanting to get ahead of any issues early, if possible.

@Eelman 

Sounds like it's a bug (Microsoft, you listening!!! 😀), UpdateIf() fixed my issue completely and an easy switch.

Thanks!

@RandyHayes 

 

UpdateIf, Works like a charm!

Thanks

@Eelman 

Yep...SharePoint too!

 

I ran into it enough that I just got used to UpdateIf for everything.  And, it's an easy transition. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes @mike528 

Thanks for getting back to me. Looks like I will also be making the transition 🙂 

The good news is that it's an easy switch. Very thankful to @RandyHayes , otherwise I might have been bailing on my Offline capability design.  

I just came across this issue too.  Wasted three hours fiddling with it.  I end up filling the column with a "-".

 

An example of UpdateIf would be helpful 😁

@WarrenBelz 

FYI, Patching blanks discussion

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,837)