cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Digital
Level 8

Patch collection to update existing SharePoint list records using ForAll

I want to patch a local collection to update existing data in a SharePoint list. The user makes some changes which get saved to a collection.

 

In the past I've successfully used the following method, but now I'm getting a runtime error:

 

error.png

 

PowerApps is indicating a problem with the following line of code:

 

First(Filter( MyList, ID = ID )

 

ForAll(
    colSavedApps,
    If(
        !IsEmpty(colSavedApps),
        Patch(
            MyApps,
            First(Filter(MyApps,ID = ID)),
            {
                Title: Title,
                spField_1: spField_1,
                spField_2: spField_2
             }
        )
    )
);

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Patch collection to update existing SharePoint list records using ForAll

Hey @Digital 

 

Can you try to update the expression as:

ForAll(
RenameColumns(colSavedApps,"ID","ID1"),
If(
!IsEmpty(colSavedApps),
Patch(
MyApps,
First(Filter(MyApps,ID = ID1)),
{
Title: Title,
spField_1: spField_1,
spField_2: spField_2
}
)
)
);

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

7 REPLIES 7
Super User
Super User

Re: Patch collection to update existing SharePoint list records using ForAll

From where are you getting your second ID value in the filter function? 

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

Digital
Level 8

Re: Patch collection to update existing SharePoint list records using ForAll

I thought from the local collection. There is a column called ID in there.

 

The local collection is pretty much a copy of the SharePoint list, but the user can select/deselect options. I want to be able to update the list once they've made their changes and hit save. I can't use a form for this.

Super User
Super User

Re: Patch collection to update existing SharePoint list records using ForAll

I think you may need to specify the two ID columns slightly differently from each other. When you start typing in ID, what suggestions do you get?

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
Digital
Level 8

Re: Patch collection to update existing SharePoint list records using ForAll

@PowerAddict ,Thanks for your reply.

 

On the left side of the condition, I get column name suggestions. On the right side I get suggestions of everything in my app - element properties, galleries, images etc, as well as column names.

 

My collection is also the data source for a gallery that displays data. Do I need to add the ID to my collection in a different column maybe? Would I do this by renaming it or adding a column?

 

 

Digital
Level 8

Re: Patch collection to update existing SharePoint list records using ForAll

I should add that if I hardcode the ID in the right side it patches. So the only issue is getting the ID of each gallery item in there so it matches the correct record to be patched.

 

First(Filter(MyApps,ID=469))
Dual Super User
Dual Super User

Re: Patch collection to update existing SharePoint list records using ForAll

Hey @Digital 

 

Can you try to update the expression as:

ForAll(
RenameColumns(colSavedApps,"ID","ID1"),
If(
!IsEmpty(colSavedApps),
Patch(
MyApps,
First(Filter(MyApps,ID = ID1)),
{
Title: Title,
spField_1: spField_1,
spField_2: spField_2
}
)
)
);

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Digital
Level 8

Re: Patch collection to update existing SharePoint list records using ForAll

@yashag2255 ,

It worked! Thank you so much.

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (7,161)