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 / Patch without Lookup, ...
Power Apps
Answered

Patch without Lookup, how can this work - i'm confused

(1) ShareShare
ReportReport
Posted on by 54

Hi,

i just reviewed some code, i wrote in the beginning of my power apps career and now im confused how that code can work properly.

Im patching a MYSQL database (adr_de) with data from a editform. The editform gets its data from a collection, that is filled with data from the mysql database adr_de.

Im writing my changes back to the collection and patch the mysql database.

First, the following code works, even though there is no lookup for the specific record?!

:

 

//Update Collection
SubmitForm(formKundeEditieren);;
//Update adr_de
Patch(
 '[Abrechnung].[adr_de]';
 {ADR_DE_EGZH_LETZTER_BESUCH: DatePickerLetzterBesuch.SelectedDate};
 {ADR_DE_EGZH_NOTIZ: txtNotiz.Text};
 {ADR_DE_FINAME1: txtFirma.Text};
 {ADR_DE_FINAME2: txtName.Text};
 {ADR_DE_STR: txtStrasse.Text};
 {ADR_DE_ORT: txtOrt.Text};
 {ADR_DE_TELEFON: txtTelefon.Text};
 {ADR_DE_TELEFON2: txtHandy.Text};
 {ADR_DE_MAIL: txtMail.Text};
 {ADR_DE_EGZH_ER_ZK: dropER_ZK.Selected.Value};
 {ADR_DE_EGZH_LKV_MGL: dropLKV.Selected.Value})

 

 

Categories:
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Are any of those columns in your patch a primary key?

  • SM-20081418-0 Profile Picture
    54 on at

    yes, there is  a field with a primary key (not listed here) , the customer ID.

    And this was patched by the app, too.🙈

  • SebS Profile Picture
    4,867 Super User 2026 Season 2 on at

    @SteMat 

     

    I believe it's same as You patch Database with Collection Patch("DataSource",Collection) patch will find its way even it's not intended future.

     

    You said you patching EditForm mean this Form contain ThisItem even if You don't manage this in the code, I bet patch manage it for you so probably another not intended future of the patch but good to know 🙂

     

    Check the collection if it does not contain some additional Reference column what's added cause You collect direct from form what Patch may use as Lookup later on without You knowing it

  • Verified answer
    iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Ok, so did some testing,

     

    The reason is that it is using the first parameter as a lookup when you specify multiple records separated by ; (for your language setting, for others it would be , )

     

    It is the same as:

     

     

    Patch(
     '[Abrechnung].[adr_de]';
     LookUp('[Abrechnung].[adr_de]'; ADR_DE_EGZH_LETZTER_BESUCH = DatePickerLetzterBesuch.SelectedDate);
     {ADR_DE_EGZH_NOTIZ: txtNotiz.Text};
     {ADR_DE_FINAME1: txtFirma.Text};
     {ADR_DE_FINAME2: txtName.Text};
     {ADR_DE_STR: txtStrasse.Text};
     {ADR_DE_ORT: txtOrt.Text};
     {ADR_DE_TELEFON: txtTelefon.Text};
     {ADR_DE_TELEFON2: txtHandy.Text};
     {ADR_DE_MAIL: txtMail.Text};
     {ADR_DE_EGZH_ER_ZK: dropER_ZK.Selected.Value};
     {ADR_DE_EGZH_LKV_MGL: dropLKV.Selected.Value})

     

     

    Patch(datasource; {recordToLookUp: recordToLookUpValue}; {update1: update1}; {update2: update2})

    iAm_ManCat_0-1669979943802.png

     

    So I would highly recommend add the customerID as your first field using something like 

     

     

    {customerID: formKundeEditieren.LastSubmit.customerID}

     

     

    as there may come a day when the dates are duplicated and it would patch the first available record it looks up with that date.

  • SM-20081418-0 Profile Picture
    54 on at

    Actually, the customer number is the first field, i just didnt want to post it here due data security reasons.

    But thats a interesting case, because it looks like the lookup function is not necessary

    for patching a specific record.

    Well anyway, it's not a good idea to patch a primary key in a database 🙂

    Thanks for your clarification.

     

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard