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 / Update collection in g...
Power Apps
Unanswered

Update collection in gallery and datasource

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

I'm having issues with updating records in a gallery to the data source. I am using this video (Create and update a collection in a canvas app (contains video) - Power Apps | Microsoft Learn) as a guide but when I try to update, it creates a new record instead of updating the existing record. How do I go about this?

Many thanks!

Categories:
  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Anonymous - what is the current code you're using to Patch the Gallery items to your data source?

     

    Below is a simple example for SharePoint:

     

    Patch (
     'Your Data Source',
     ForAll(
     Gallery1.AllItems,
     {
     ID: ID,
     field_1: TextInput1.Text
     }
     )
    )

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

    Imran-Ami Khan

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I am using patch to get items from user inputs and send over via Excel. The code I'm using is:

    Patch(
    collection1,
    ThisItem,
    {
    BOLNo: BOLNoinput.Text,
    ArrivalTime: ArrivalTimeinput.Text,
    BranchNo: BranchNodropdown.Selected.Value,
    DateReceived: DateReceivedinput.SelectedDate,
    DeliveryQuality: DeliveryQualitydropdown.Selected.Value,
    DepartureTime: DepartureTimeinput.Text,
    PointofContact: PointofContactinput.Text,
    NotificationofLateDeliveryvia: Notifoflatedropdown.Selected.Value,
    'MasterLoad ': MasterLoadinput.Text,
    IssueCode: IssueCodedropdown.Selected.Value,
    ProductNumberOrdered: ProductOrderedinput.Text,
    ProductNumberShipped: ProductShippedinput.Text,
    QtyOrdered: QtyOrderedinput.Text,
    QtyReceived: QtyReceivedinput.Text,
    QtyShipped: QtyShippedinput.Text,
    ServiceFailure: Switch(
    Checkbox2.Value,
    true,
    "Yes",
    "No"
    ),
    CustomerFailure: Switch(
    Checkbox1.Value,
    true,
    "Yes",
    "No"
    ),
    XFRNo: XFRNoinput.Text,
    Comments: Commentsinput.Text
    }
    );

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @Anonymous whether you are patching a Collection or patching the Data Source, if the Patch expression cannot locate a matching record to update, a new item is created by default.

     

    I assume you're also patching collection1 back to your data source?

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard