Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 8E/FiL+FijeB6Uwj3wvkem
Power Apps - Building Power Apps
Answered

Patch() for collection to sharepoint with over 120 columns?

Like (0) ShareShare
ReportReport
Posted on 5 Jun 2020 06:52:06 by 39

Hello,

I am working on a solution to my problem for a few days now.

The App works based on different SharePoint-Lists. I import a list (~15-20 rows with ~120 columns each) into a Collection with ClearCollect(). The app will modify the collection in different rows and columns. The changes made can be very little (2-3 changes) or entire rows that get changed (100+ changes). 

The user should be able to upload the collection back into the SharePoint by pressing a button. I know that I can use patch() for that, but I don't understand how. Is there an easy way to blindly copy the whole collection back into the SharePoint? I don't need to look for changes made. Overwriting the old list with the Collection in the app would be all I need. 

If patch() is the only option, can someone give me an example?

I will add a small Table with the first few columns of my list/collection. The table starts with some object specific information. The pattern of ColumnH-J (2x Yes/No, 1x text) will repeat for ~40 times. 

 

'ClearCollect(LocalCollection;'DN-OK')'

LocalCollection:

ColumnAColumnBColumnCColumnDColumnEColumnFColumnGColumnHColumnIColumnJ
texttexttexttextdatedatetextYes/NoYes/No

text

 

I started using PowerApps 2 months ago. I learn new things every day, but patch() is something I didn't understand so far. Looking into allready asked questions gave me even more '???' in my head. 

I hope to lift some blockers in my head and work towards a solution to my problem. 

 

If you have any questions, feel free to ask!

Thank you for your time and help! 😊

  • v-yutliu-msft Profile Picture
    on 08 Jun 2020 at 09:39:57
    Re: Patch() for collection to sharepoint with over 120 columns?

    Hi @Suni ,

    Yes. If you use ForAll and Patch, you could copy data from collection to sharepoint list.

    You  need to point out which filed is used to update which field.

    The field in collection could be used for multiple times to update sharepoint list.

    I suggest you read this blog in details:

    https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/

     

     

    Best regards,

  • Suni Profile Picture
    39 on 05 Jun 2020 at 09:32:44
    Re: Patch() for collection to sharepoint with over 120 columns?

    The field types shouldnt change (at least not intendet). I use ClearCollect() to import from SharePoint into the app. After that, all I do is EditForm. The SharePointList contains a mix of 'single line of text', 'multiple lines of text', 'Yes/No' and 'date and time' fields.

     

    The ForAll() Solution looks easy to implement for me. It will simply copy the value of the CollectionField 1x1 into the SharePointField 1x1, 1x2 into 1x2 and so on? 

  • Verified answer
    v-yutliu-msft Profile Picture
    on 05 Jun 2020 at 09:09:19
    Re: Patch() for collection to sharepoint with over 120 columns?

    Hi @Suni ,

    Do you want to use a collection to update a sharepoint list?

    If you use Collection to update, you need to make sure:

    1)all the field names are the same in two sides

    2)all the field data type are the same in two sides

    It seems like your situation is not like this.

    So I suggest you use ForAll and Patch to update.

    Could you tell me the field data type in sharepoint list?

    I assume that they are same as your fields in your collection.

    Then try this:

    ForAll(LocalCollection
     Patch('DN-OK', 
     Defaults('DN-OK'),
     {field1inlist: ColumnA,field2inlist: ColumnB,field3inlist: ColumnC,field4inlist: ColumnD,field5inlist: ColumnE,field6inlist: ColumnF,...}
     )
     )

    To sum up, in this solution the two sides' fieldname and data type could be different.

     

    Here's a doc about how to updating multiple line in details for your reference:

    https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/

     

     

     

    Best regards,

  • Suni Profile Picture
    39 on 05 Jun 2020 at 08:40:17
    Re: Patch() for collection to sharepoint with over 120 columns?

    I use ClearCollect to import the SharePointList at the begining. The user can choose between different lists (all departments have seperate SharePointLists, but they are all build exactly the same). 

     

    The user will pick an item from the Collection (he can browse through the items with a gallery). The survey is done with EditForm. The app will ask questions and write the answeres into 3 columns for each question (Question 1 is CloumnJ-H). All of that is done with EditForm. 

    I hope this answeres the question how I have my data in powerapps.. 😁

     

    I will only edit the Value of the fields (example ColumnName 'Is the car dirty?', value in the field for car XYZ can be YES or NO). The Question itself (Headline of the Column) will never be changed.

     

    I was looking into collect() to write everyting back, but it seemed like it would add new rows instead of overwriting the already existing rows, or am I wrong? 

     

    Where is the difference between a form and a collection? What does 'YourForm.updates' do? 

  • Mx81 Profile Picture
    860 on 05 Jun 2020 at 08:14:41
    Re: Patch() for collection to sharepoint with over 120 columns?

    It depends on....

     

    how do you have the data in powerapps? In a form?

    dann you can use this:

     

    Patch(SharePointList,Filter(SharePointList,Id=sharepointId),YourForm.updates)

     

     

    if the fields (columns) in your app has the same name as in SharePoint you can use collect(SharePointList,YourPowerAppsCollection) to patch it all at once. 
    ClearCollect doesn’t work here!!!

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
MS.Ragavendar Profile Picture

MS.Ragavendar 14

#2
LC-26081402-0 Profile Picture

LC-26081402-0 10

#3
stampcoin Profile Picture

stampcoin 6

Overall leaderboard