cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

9 REPLIES 9
Highlighted
Super User III
Super User III

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Highlighted

@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.

Highlighted

@Eelman 

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

Thanks!

Highlighted

@RandyHayes 

 

UpdateIf, Works like a charm!

Thanks

Highlighted

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Highlighted

@RandyHayes @mike528 

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

Highlighted

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.  

Highlighted

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 😁

Highlighted

@WarrenBelz 

FYI, Patching blanks discussion

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (12,060)