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

@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.
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_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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