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 Azure SQL record
Power Apps
Unanswered

Update Azure SQL record

(0) ShareShare
ReportReport
Posted on by 2
I am connecting to a azure sql db (DB_A) , loading a collection (COL_B) for the selected record in the gallery displaying Azure DB records.

After updating the COL_B in an edit form, I am trying to write COL_B back to DB_A.

This does not seem to be the correct syntax:

Patch( '[dbo].[DB_A]',Defaults('[dbo].[DB_A]'),
{Field1: COL_B.Field1,
Field2: COL_B.Field2,
Field3: COL_B.Field3

})
Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    In the Patch function, the defaults() is used to create a new record.  If you are editing a record you should use LookUp() or some other method to find the record being updated before you patch it.  

    quoting from the formula reference for Patch(): 

    • To modify a record, the base record needs to have come from a data source. The base record may have come through a gallery's Items property, been placed in a context variable, or come through some other path. But you should be able to trace the base record back to the data source. This is important as the record will include additional information to help find the record again for modification.

    So for your collection, the record you are editing should have an ID field derived from DB_A.that can be traced back:

    Patch( '[dbo].[DB_A]', LookUp('[dbo].[DB_A]'),ID=COL_B.ID),
    {Field1: COL_B.Field1,
    Field2: COL_B.Field2,
    Field3: COL_B.Field3

    })

     

    There is a good discussion of the patch funciton here:

    https://powerusers.microsoft.com/t5/General-Discussion/Using-the-Patch-function-to-either-create-OR-update-a-record/td-p/51636

  • seanthare Profile Picture
    2 on at

    I am still having an issue witht the syntax of the Patch function to update the Azure SQL record.

     

    I have A FieldSK in the DB_A as the primary key - So I would think that is my link from COL_B back to DB_A

     

    Patch( '[dbo].[DB_A]', LookUp('[dbo].[DB_A]'),[dbo].[DB_A].FieldSK=COL_B.FieldSK),
    {Field1: COL_B.Field1,
    Field2: COL_B.Field2,
    Field3: COL_B.Field3

    })

     

    This still gives me me 'invaild number of arguments'

     

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

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard