cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kgordish
Resolver I
Resolver I

Patch Existing Record

Hello, 

Having Issues Patching existing records in SharePoint. 

 

I have a gallery named: ExcelGallery
Items: SortByColumns(Filter(Gateways, MasterID = ProgramGallery.Selected.ID),"Date")

kgordish_0-1655747748890.png

Have a hidden toggle to detect changes
Defaults:
ThisItem.'Year' <> YearInput.Text ||
ThisItem.'Field' <> FieldInput.Text ||

 

Patch Formula:
ForAll(Filter(ExcelGallery.AllItems, Toggle1.Value = true),
Patch(Gateways, ThisRecord, {'Year': YearInput.Text}));
Navigate(Home)

 

Saving to SharePoint and Currently Title field is not being used/required.
Don't know why data is not getting updated. Is there an issue with using ThisRecord?

 

Thanks in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Ah, it makes a difference if controls such as VPPDateInput are located within the gallery. In that case, try revising your code as shown to capture the separate values in each gallery item:

ForAll(
    Filter(ExcelGallery.AllItems, Toggle1.Value = true) As aRecord,
    Patch(Gateways, aRecord, 
    {
        ModelYear: MYInput.Text,
        Program: ProgramInput.Text,
        Ref_Only_Drop: {Value: RefOnlyInput.Selected.Value},
        VPPDate: aRecord.VPPDateInput.SelectedDate
    })
);

You may also want to similarly edit the control references for MYInput, ProgramInput, and RefOnlyInput if those are also located within the gallery.

 

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
BCLS776
Super User
Super User

A ForAll()-Patch() combination needs an As operator to help resolve ambiguity:

ForAll(Filter(ExcelGallery.AllItems, Toggle1.Value = true) As aRecord,
Patch(Gateways, aRecord, {'Year': YearInput.Text}));
Navigate(Home)

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
kgordish
Resolver I
Resolver I

@BCLS776 Thanks Bryan. Wish I could buy you a cold beverage or send a tip. Thanks. 

kgordish
Resolver I
Resolver I

@BCLS776  This patch seems to be treat different lines of data as the same. If I make multiple date

ForAll(Filter(ExcelGallery.AllItems, Toggle1.Value = true) As aRecord,
Patch(Gateways, aRecord, {ModelYear: MYInput.Text,
Program: ProgramInput.Text,
Ref_Only_Drop: {Value: RefOnlyInput.Selected.Value},
VPPDate: VPPDateInput.SelectedDate}));
Navigate(Home);
Refresh(Gateways)

 

Before: 

kgordish_0-1655818828170.png

Change Dates to 28, 29, and 30. Saves all three dates as 30.  Any advice on how to avoid this situation? 

kgordish_2-1655818961884.png

 

Ah, it makes a difference if controls such as VPPDateInput are located within the gallery. In that case, try revising your code as shown to capture the separate values in each gallery item:

ForAll(
    Filter(ExcelGallery.AllItems, Toggle1.Value = true) As aRecord,
    Patch(Gateways, aRecord, 
    {
        ModelYear: MYInput.Text,
        Program: ProgramInput.Text,
        Ref_Only_Drop: {Value: RefOnlyInput.Selected.Value},
        VPPDate: aRecord.VPPDateInput.SelectedDate
    })
);

You may also want to similarly edit the control references for MYInput, ProgramInput, and RefOnlyInput if those are also located within the gallery.

 

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
kgordish
Resolver I
Resolver I

That worked. Thank you.

 

ForAll(Filter(ExcelGallery.AllItems, Toggle1.Value = true) As aRecord,
Patch(Gateways, aRecord, {'Model Year': aRecord.MYInput.Text,
Program: aRecord.ProgramInput.Text,
Reference_Only: {Value: RefOnlyInput.Selected.Value},
'VPP Dates': aRecord.VPPDateInput.SelectedDate}));
Navigate(Home);
Refresh(Gateways)

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

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

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,244)