Skip to main content

Notifications

Community site session details

Community site session details

Session Id : iiepk3IVuXGQHTXCaeHMOt
Power Apps - Building Power Apps
Answered

Patch a collection of items to SharePoint List

Like (0) ShareShare
ReportReport
Posted on 3 May 2018 18:51:19 by 69

Hi All,

 

I'm struggling with this one.  I have a use case where I would like to be able to use my app to create offline stats for childrens football (mainly because it would take too long to interact with sharepoint and I might not even have good reception).

 

I have a collection that I am trying to post to sharepoint.  SpotsStats is my Sharepoint List.  cnStats is my collection.

 

 

SportStats.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The following syntax works (although it is nonsense!)

ForAll(cnStats,
Patch(SportStats, Defaults(SportStats),
{Weather: "My Weather Test"}))

 

When this code runs I end up with 4 rows in sharepoint (corresponding to the fact I have 4 rows in my collection).

 

My real objective is to do something along the following lines (see below) but it's not working:-

 

ForAll(cnStats,
Patch(SportStats, Defaults(SportStats),
{ ActionIndex: cnStats.Index, Action: cnStats.Action, Half: cnStats.Half,Result: cnStats.Result,Weather: cnStats.Weather})

 

Even the following is invalid syntax

 

ForAll(cnStats, 
Patch(SportStats, Defaults(SportStats), 
{Result: cnStats.Result})

 

This would suggest that the problem is with the cnStats.Result.  I've tried wrapping this in a text function Text(cnStats.Result) but still no joy.

 

Any ideas what I'm missing as it's pretty frustrating.

Categories:
  • ScottRMeredith Profile Picture
    133 on 22 Dec 2021 at 15:47:25
    Re: Patch a collection of items to SharePoint List

    @SergiP 

    I got it worked out as I forgot I had extra columns in my collection that were not on my sharepoint list.  I ended up creating a new collection with just the columns I needed and it worked.  Thanks for the reply.  

  • SergiP Profile Picture
    118 on 22 Dec 2021 at 15:40:48
    Re: Patch a collection of items to SharePoint List

    hi ScottRMeredith,

    I would say that your collection CalShopCart already has a column called "field_0", and this is the Name column... that's why you can't add a 2nd column with the same name.

    It's a total pain when the column names get all jacked up so I suggest to recreate the Sharepoint List... If you have it on an Excel file it should be very easy to create it again and reuse your previous data and a new List. Make sure your table column name have no space or weird character to avoid jacked names again.

  • ScottRMeredith Profile Picture
    133 on 15 Dec 2021 at 04:18:34
    Re: Patch a collection of items to SharePoint List

    @Shanescows or @Rick72 

     

    I am using Shane's video to create a shopping cart app.  I got my initial patch working to my parent list and capturing the ID of the newly created record.  When I try to do the collect formula to patch the child list I get the below warning/error message.

    ScottRMeredith_2-1639541755146.png

     

    I created my SP list from an Excel file table and my URL based column names got all jacked up.

    ScottRMeredith_1-1639541716117.png

     

    I have tried both field_0 and OrderID, but get the same error.  I even tried with out the quotes surrounding it.  Below is my list column data and then my collection data from a sample collection I loaded up.

    ScottRMeredith_3-1639541855168.png

    ScottRMeredith_4-1639541872131.png

    I don't have any other ideas on how to get my child list to patch.

     

    Thanks in advance.

     

  • sodhir2 Profile Picture
    4 on 26 May 2021 at 20:09:32
    Re: Patch a collection of items to SharePoint List

    Unable to patch a lookup column in SharePoint list. I am trying to bulk update just one column and since it is a lookup, I am going in circles to a point I have rely on online expertise for this.

    Nothing has been working out. I wish I could get rid of that lookup column .. I am going bonkers updating. 

    I have 2 collections.

    #1. ClearCollect(colNewReports,'New Reports') /* This is a straight collection from sharepoint list*/

    I have a gallary with checkboxes for each item that is pointing to ColNewReports collection.
    #2. OnCheck, I am collecting checked items into a new collection called Collect(colNewReports_updates,ThisItem)

     

    I am trying to patch just one column called product owner in 'New Reports' Sharepoint list from colNewReports_updates. 

    I have tried 2 ways of patching this but it won't apply any change. I am able to patch colNewReports_updates .. no problem but I can't patch SharePoint list from this colNewReports_updates. Performance is another thing I have consider as it is going to be bulk update. 

    #Approach 1. ForAll(
    Filter(
    gal_hub_1.AllItems,
    Checkbox1_2.Value = true
    ),
    Patch(
    colNewReports_updates,
    LookUp(
    colNewReports_updates,
    ID exactin lbl_idtext.Text
    ),
    {
    'Product Owner': {
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: 0,
    Value: rad_owner.Selected.Result
    }
    }
    )
    );
    Patch(
    'New Reports',
    colNewReports_updates
    );

    ****
    #Aprroach 2.
    ForAll(
    Filter(
    gal_hub_1.AllItems,
    Checkbox1_2.Value = true
    ),
    Patch(
    colNewReports_updates,
    LookUp(
    colNewReports_updates,
    ID exactin lbl_idtext.Text
    ),
    {
    'Product Owner': {
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: 0,
    Value: rad_owner.Selected.Result
    }
    }
    )
    );
    Patch('New Reports',
    LookUp(
    colNewReports_updates,
    ID exactin 'New Reports'.ID
    ),
    {
    'Product Owner': {
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id: 0,
    Value: rad_owner.Selected.Value
    }
    }
    )
    ;

     

     

  • CadelDev Profile Picture
    74 on 22 Mar 2021 at 16:35:52
    Re: Patch a collection of items to SharePoint List

    I'm having a similar issue. I have Collect(MySharePointList, MyCollection) but it states
    "The specified column "ColumnName" doesn't exist. The column with a similar name is "ColumnName" and I don't understand what's going on.

  • Community Power Platform Member Profile Picture
    on 23 Sep 2020 at 22:07:42
    Re: Patch a collection of items to SharePoint List

    Hi Shane,

     

    This approach is no longer working on my end, though it used to for a long time. Are you aware of other ways to patch the whole collection to a SP list?

     

    Thank you,

    Yulia

  • Community Power Platform Member Profile Picture
    on 12 Jun 2020 at 11:08:47
    Re: Patch a collection of items to SharePoint List

    Thank you so much for your reply however how can I have the results from that column go to the correct column in the Sharepoint?

     

    Collect(KIT, Filter(myCollecttion1,'ATP QTY'))

     

    This is what I have so far where KIT is the name of the sharepoint, myCollecttion1 is the name of the Collection and ATP QTY is the field in the collection but the column in Sharepoint is ATP Quantity (SP).

  • SergiP Profile Picture
    118 on 12 Jun 2020 at 06:14:01
    Re: Patch a collection of items to SharePoint List

    you can filter the item you want to update and then patch it to the SP List

  • Community Power Platform Member Profile Picture
    on 11 Jun 2020 at 20:48:24
    Re: Patch a collection of items to SharePoint List

    Hi @Shanescows ,

     

    I have a PowerApp where I am bringing in fields from multiple data sources into a Collection. If I want to patch just one of those fields from my Collection to a Sharepoint lists, how would I do that since it's not all fields?

     

    thank you!

  • bbar0121 Profile Picture
    50 on 16 Mar 2020 at 15:24:58
    Re: Patch a collection of items to SharePoint List

    @Shanescows  How does "Collect(SharePoint, Collection)" patch all of the records in the collection?

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

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard