web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Again, how hard can th...
Power Apps
Answered

Again, how hard can this be

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

Categories:
  • mdevaney Profile Picture
    29,993 Moderator on at

    @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."

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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

  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

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

     

    Chris

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard