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 / How to patch a collect...
Power Apps
Answered

How to patch a collection column values in a Canvas App to a SP List column values with a click of a button?

(0) ShareShare
ReportReport
Posted on by 559

Hi:

Trying to Patch a Collection Column titled "Active" values from the collection to a SharePoint List Boolean column titled "Active" with a click of a button (See Attached)

SP List:  ARMStasks

Main Collection: colGalTasksData  (Stores all the records from ARMStasks)

Sub Collection:   colSelected  (Stored selected records by a check box in a Gallery)

PowerApps Archive Screen:  - Displays Gallery with Data source = colGalTasksData

                                             - Allows user to select an individual or all the Record(s) using the check Box(s).

                                             - Allows User to select the Archive Status in dropdown drpArchiveStatusAT (2 options Active, Inactive)

Load Data Button -                 Loads data from SP list in the Collection colGalTasksData

Update Data Button -             Updates the Collection colGalTasksData with changes made in the Gallery using Check Boxes.

Save Data Button -                 Saves data from the collection to the SP List - The Script below gives an error.                          

Save Data Button Script for OnSelect property - that is not working:

ForAll(
colGalTasksData as MyCollection,
Patch(
ARMStasks,
ID:MyCollection.ID
{Active:MyCollection.Active.Value}
)
);

 

Need help in resolving the error(s).

Thank you,
SueA.

ColPatchToSPlist.png
Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,545 Most Valuable Professional on at

    Hi @SueA ,

    Try this

    Patch(
     ARMStasks,
     ForAll(
     colGalTasksData As MyCollection,
     {
     ID: MyCollection.ID,
     Active:
     If(
     MyCollection.Active,
     "Active",
     "Inactive"
     )
     }
     )
    );

    Note also that ForAll()  is not designed to be a Loop, although it can work this way with considerable performance penalty as it does an individual Patch for each record. ForAll() creates a Table, which can be patched in one action provided its content is correct. For new records, this is simply a Table with field names and field types matching the list. For existing records, including the SharePoint record ID in the table causes it to update that record for each of the Table records.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • SueA Profile Picture
    559 on at

    Hi @WarrenBelz 

    Understood the concept. Many thanks.

    But, still having a bit of an issue even after I fixed the query for the Boolean values in the SP list. Please see the attached.

    Thoughts?

  • SueA Profile Picture
    559 on at

    Hi @WarrenBelz 

    To fix my issue, I needed to restart my laptop and reload the PowerApps! 😞

    It is now working as intended. Below is my final Query. It is exactly the same Query as what you gave me above but as both my collection as well as SP list have "Active" column as of Boolean Data Type, with a small modification, the final query is as shown below:

    Patch(
    ARMStasks,
    ForAll(
    colGalTasksData As MyCollection,
    {
    ID: MyCollection.ID,
    Active: MyCollection.Active
    }
    )
    );

    Many Thanks.

    As always, in appreciation.
    SueA.

     

     

  • WarrenBelz Profile Picture
    156,545 Most Valuable Professional on at

    Hi @SueA ,

    I thought the Active column was Text based on your screenshot (hence my conversion to Text)

    WarrenBelz_0-1698455882629.png

    otherwise my response would have been exactly as per your current code.

     

  • SueA Profile Picture
    559 on at

    @WarrenBelz 

    Yes, that was totally my bad. I'd forgotten about that, sorry...

    Also, in continuation, I have another hiccup....

    If possible, please see the post below.

    https://powerusers.microsoft.com/t5/Building-Power-Apps/In-my-Canvas-App-how-do-I-update-related-SP-TASKS-list-data/m-p/2425035#M604813

    Thank you,
    SueA.

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 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard