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 / Struggling to patch co...
Power Apps
Answered

Struggling to patch collection to sharepoint list

(0) ShareShare
ReportReport
Posted on by 133

Screenshot 2023-10-13 at 16.41.03.png

Hi All

 

Need help with sending data from a collection to a sharepoint list. I am using the collect function - columns names on both 'collection' and 'sharepoint list' are the same. however, I am getting the attached error but am struggling to fix.... any ideas - Column Cost Code in collection 'orderlist' does exist? 

Categories:
  • Verified answer
    BrianS Profile Picture
    2,407 Super User 2024 Season 1 on at

    I seems to me that I ran into this issue a few apps ago. I believe I ended up putting a RemoveColumn function around the collection and pulled out a number of the automatically created columns.

    You could check to see if that column really in the SP list is the actual name - sometimes it gets wonky. If you go to the List settings page and hoover your mouse over the column name it will display a long string at the bottom of the window. The real name of the column will display at the end of the string. 

  • Anchov Profile Picture
    1,986 on at

    To achieve this, follow these steps:

    1. Utilize the ForAll function to iterate through each row of your collection.

    2. Use the Patch function to either create new rows in your SharePoint list or update existing rows. Ensure that you map each column in your collection to the correct column in your SharePoint list.

     

     

    ClearCollect(colYourCollection, galYourGallery.AllItems); //Initiate your collection 
    ForAll(
     colYourCollection As item, //can also directly reference your gallery with galYourGallery.AllItems
     Patch(
     'SharePointList', //your datasource
     //Choose if adding new rows vs updating existing rows
     If(
     IsBlank(item.ID),
     Defaults('SharePointList'), //new Item
     LookUp(
     'SharePointList',
     ID = item.ID
     ) //existing item lookup
     ),
     {
     Title: item.Title,
     'Reviewer Status': item.Status.Value,
     'Reviewer Date': item.ReviewerDate,
     Comments: item.Comments
     }
     )
     );
    

     

     


    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

    Cheers!
    Rick Hurt

  • BrianS Profile Picture
    2,407 Super User 2024 Season 1 on at

    ForAll will work, but it is not nearly as performant as using Collect - it also requires much more code

  • BaseHQ Profile Picture
    133 on at

    Thank you @BrianS 

    I changed the name of the 'cost code' column in the SP list (removed the space - costcode) and this push the collection with no problem. Appreciate the suggestion. 

  • BaseHQ Profile Picture
    133 on at

    Thank you @Anchov - appreciate you taking the time to help! really appreciated...

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard