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

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

@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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (67,767)