cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SlavaS1
Helper II
Helper II

Patch doesn't work for a gallery

Hello,

I have an edit form for a SharePoint list (Payments) and there is a subtable/gallery for another SharePoint list (Payment lines) on the form.

 

I am trying to patch all gallery items when I click on the save button, however nothing happens, no errors. I have looked a lot of posts and tried to do the same, but no luck.

 

Could you please advice what I do wrong?

gPaymentLines - Gallery

Payment Request Lines - Data source (SharePoint list), that is used on the gallery.

 

 

ForAll(
       RenameColumns(
           Filter(
            'Payment Request Lines',
            ID in gPaymentLines.AllItems.ID
           ),
            "ID",
            "DD"
        ),
    Patch(
        'Payment Request Lines',
    LookUp(
        'Payment Request Lines',  
        DD = ID
        ), 
    {
        Units:"u3", 
        AccountCode:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                Id: cbAccountCode.Selected.ID,
                Value: cbAccountCode.Selected.Title
            }
    }
    )
);

 

FormToPatch.png

5 REPLIES 5
RandyHayes
Super User
Super User

@SlavaS1 

This formula should be on the OnSuccess action of your Primary EditForm.  Consider changing to the following:

Patch('Payment Request Lines',

    ForAll(gPaymentLines.AllItems As _item,
        {
          ID: _item.ID,
          Units: "u3", 
          AccountCode:{
                Id: _item.cbAccountCode.Selected.ID,
                Value: _item.cbAccountCode.Selected.Title
            }
        }
    )
);

 

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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes  thank you for your quick and detailed reply, however it doesn't work for me. I put a message on OnSuccess trigger and I see that the function was called, however nothing happened. I even simplified the formula and kept updating one text field only.

 

Please see the video how it works.

https://www.screencast.com/t/XjJe7zrr6A 

 

FormToPatch2.png
Could you please advise what I am doing wrong?

 

Thank you for advance.

 

I was able to patch a single record by hard coding ID

But I still cannot iterate through galley items

 

FormToPatchHardCode.png

RandyHayes
Super User
Super User

@SlavaS1 

What is the Items property of gPaymentLines?

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes ,

Gallery Items:

Filter('Payment Request Lines', PaymentRequest.Id=ItemSelected)

 

The PaymentRequest field is a lookup on the parent list, one PaymentRequest may have some Payment Request Lines.

 

The filter works good and I can see related rows:

FormToPatchTable.png

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 (5,611)