cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kiwi22
Frequent Visitor

Patch Issue

Hi Guys

 

Hope you can assist? I've got a vehicle check app that allows users to update things like Registration expiry and Service due information. This works only if I'm updating one field at a time. If I try to change more than one of these fields, it defaults back to the previous values. The formula I'm using is: 

 

Patch(ListVeh2,ThisItem, {'Wof Expiry':DPCChangeWOFDATE.SelectedDate,'Registration Expiry':DPCChangeRegistrationDATE.SelectedDate,'COF Expiry':DPCChangeCOFDATE.SelectedDate,'Service Due kms':Value(UpdateServicekms.Text)})

 

Any help would be appreciated. Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

Your code is correct.  The problem is that you aren't setting the defaults on the DatePickers using the default values in the item being edited.  So when you Patch its picking up the date field that you changed, but all the rest are being set back to the defaults in the datepickers.  Make sure the DatePicker for each field defaults to the value in the field when you edit the record.  Then whichever field you change that field will be saved when you Patch and the other fields will overwrite the existing values with the values that are already saved.  Make sure you do the same for UpdateServicekms too.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
Pstork1
Dual Super User
Dual Super User

Your code is correct.  The problem is that you aren't setting the defaults on the DatePickers using the default values in the item being edited.  So when you Patch its picking up the date field that you changed, but all the rest are being set back to the defaults in the datepickers.  Make sure the DatePicker for each field defaults to the value in the field when you edit the record.  Then whichever field you change that field will be saved when you Patch and the other fields will overwrite the existing values with the values that are already saved.  Make sure you do the same for UpdateServicekms too.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

That makes sense, thank you very much. Would something like CurrentDate() work in the default value?

 

yes you can set the default to the currentDate, but if you do that all the fields that you don't edit will get set to the current date.  I thought that was what you were trying to avoid.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Sorry, you're right. I didn't phrase my question correctly.  I've changed the default to ThisItem."Field I want to show if it's empty". I've done some testing and this seems to have worked, thank you very much for the help.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,798)