cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Again, how hard can this be

I want something very simple but it seems that a simple answer is very complex. How to update the current filtered gallery records that I see to SharePoint list using a button. Tried many things on this site like patch default. Patch first, Collection items etc. but somehow it's difficult to come to the correct answer. So far, the best results I have is that new records are created.

Thanks

Chris

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous ,

 

Do you mean you want to update these gallery items to corresponding sharepoint list records?

 

If so, just use LookUp function to find the corresponding record that needs to be updated.

ClearCollect(colExportData, MyGallery.AllItems);
ForAll(colExportData, Patch('myDataconnectiontoSharepointlist', LookUp('myDataconnectiontoSharepointlist',ID=colExportData[@ID]), {MyColumninSharepointlist: GalleryControlName.Text, MySecondColumninSharepointlist: GalleryControlName2.Text } ) )  // update the value of control in gallery to sharepoint list

Or

ClearCollect(colExportData, MyGallery.AllItems);

ForAll(colExportData, Patch('myDataconnectiontoSharepointlist', LookUp('myDataconnectiontoSharepointlist',ID=colExportData[@ID]), {MyColumninSharepointlist: colExportData[@FieldinSharepointList], MySecondColumninSharepointlist: colExportData[@FieldinSharepointList] } ) )  // update the value of field in gallery to sharepoint list

Hope this helps.

Sik

View solution in original post

4 REPLIES 4
mdevaney
Super User III
Super User III

@Anonymous 

There are 2 generic methods to do this.  To give a better response I would need to know more about your app.

 

#1  Loop through the gallery items and PATCH any specified fields.

ClearCollect(colExportData, Gallery1.AllItems);
ForAll(
    colExportData,
    Patch(
        your_sharepoint_list,
        Defaults(your_sharepoint_list),
        {FieldName1: colExportData[@FieldName1],
         FieldName2: colExportData[@FieldName2],
         FieldName3: colExportData[@FieldName3]
        }
    )
)

 

#2 Insert all of the gallery items & data  into the sharepoint list.  This would require matching column names in both the gallery and the sharepoint list.

Collect(your_sharepoint_List, Gallery1.AllItems);

 

Again, these are just general methods...

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Anonymous
Not applicable

mdevaney,

 

Thanks for the reply. Your suggestion is not working. It creates, at best, new records with the same value. Not new value at same records. Done the following:

 

ClearCollect(colExportData, MyGallery.AllItems); ForAll(colExportData, Patch('myDataconnectiontoSharepointlist', Defaults('myDataconnectiontoSharepointlist'), {MyColumninSharepointlist: colExportData[@MyFieldinGallery], MySecondColumninSharepointlist: colExportData[@MyFieldinGallery] } ) )

Using this I get an error. Requested operation is invalid.

 

If I'm using:

 

ClearCollect(colExportData, MyGallery.AllItems); ForAll(colExportData, Patch('myDataconnectiontoSharepointlist', Defaults('myDataconnectiontoSharepointlist'), {MyColumninSharepointlist: colExportData[@FieldinSharepointList], MySecondColumninSharepointlist: colExportData[@FieldinSharepointList] } ) )

new records are created with incorrect information, however not working correct either.

 

Keep notice that I'm having a filter on this gallery and I want only the filtered items to be updated to the SharePoint list.

 

My Question at first, Do I need Defaults or do I need First?

 

Thanks, this is taking me almost a week already so help is welcome.

 

Chris

Hi @Anonymous ,

 

Do you mean you want to update these gallery items to corresponding sharepoint list records?

 

If so, just use LookUp function to find the corresponding record that needs to be updated.

ClearCollect(colExportData, MyGallery.AllItems);
ForAll(colExportData, Patch('myDataconnectiontoSharepointlist', LookUp('myDataconnectiontoSharepointlist',ID=colExportData[@ID]), {MyColumninSharepointlist: GalleryControlName.Text, MySecondColumninSharepointlist: GalleryControlName2.Text } ) )  // update the value of control in gallery to sharepoint list

Or

ClearCollect(colExportData, MyGallery.AllItems);

ForAll(colExportData, Patch('myDataconnectiontoSharepointlist', LookUp('myDataconnectiontoSharepointlist',ID=colExportData[@ID]), {MyColumninSharepointlist: colExportData[@FieldinSharepointList], MySecondColumninSharepointlist: colExportData[@FieldinSharepointList] } ) )  // update the value of field in gallery to sharepoint list

Hope this helps.

Sik

View solution in original post

Anonymous
Not applicable

Thanks v-siky-msft, this did the trick.

 

Chris

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

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

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,918)