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 to SQL not working
Power Apps
Answered

PATCH to SQL not working

(0) ShareShare
ReportReport
Posted on by 56

Hi there, 

Still in the process of building out my app. 

I'm trying to PATCH a new record to SQL but I cant get the right formula when dropdowns are involved. 

I have tried .Selected.Text, .Selected.Value, .Selected.Result, .Selected and keep getting errors.

The only time the code doesn't throw an error is when I use these values highlighted.

kpechal150_5-1691439160708.png

 

Which come from this code below where I am adding a blank to the dropdowns. But nothing happens when I run the Patch code since that's a reference to the blank and not the actual selected value. But .Selected.DataTypes isnt an option...

kpechal150_2-1691438086875.png

 

Example Selected.Value not working -

kpechal150_4-1691438964701.png

 

 

What am I missing here? Please help. Let me know if you need more info.

Note - the SQL table PK is an identity column that auto generates. 

 

Follow up question - 

If I can get this working to create new records, I want to then create a variable that once saved to SQL, the identity SQL number "Inventory ID" is returned. Can this be worked into the same code as above?

kpechal150_6-1691439567081.png

 

 

Code for editing:

 

Patch(EXPL_inventorytest,
Defaults(EXPL_inventorytest),
{
MediaBarcode: tMB.Text,
DataType: ddDataType.Selected,
Country: ddCountry.Selected,
MediaType: ddMediaType.Selected,
MediaNumber: tMediaNumber.Text,
Location: ddLocation.Selected,
DigitalFormat: ddDigitalFormat.Selected,
DataDescription: tDataDescription.Text,
RecordCreatedBy: tRecordCreatedBy.Text,
RecordCreatedDate: dpRecordCreatedDate.SelectedDate
}
)

 

 

Categories:
I have the same question (0)
  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at

    What data types are the columns in SQL you are writing to? Have you tried just plugging in dummy "Test" text there to make sure it works? 

     

    Hover over the ungroup or select it and what all is returning? Is it multiple columns? Could be .Results but if you have multiple coumns coming in It'll be different than just value as there is multiple rows. 

     

    As for the returning the ID, you can just use the Patch(Patchcode).ID to get the ID back from it. So you can put it in a variable when you execute the patch, so Set(varRecordID, Patch(Patchcode).ID) for example will save the ID into the varRecordID variable. 

  • kpechal150 Profile Picture
    56 on at

    I have found the error and made a few modifications - 

    The issue was with the dropdown Items code where I was trying to include a blank value. I have changed the dropdown code to this:

    kpechal150_6-1691519371716.png

     

    And updated my OnSelect code of my save button to this: 

    kpechal150_7-1691519400611.png

     

    However, now when I run it it looks like its processing but ultimately gives me this error and no other information:

    kpechal150_8-1691519451864.png

     

    There's no formula errors but there are some performance errors. Though It wont let me see the entire message!? 

    kpechal150_9-1691519617484.png

    kpechal150_10-1691519663831.png

    So I update my dropdown code to:

    kpechal150_11-1691519737277.png

    And I get same error with no information as to why - 

    kpechal150_13-1691519870624.png

     

    Could this be an issue with SQL and not PowerApps?

     

    Thanks!

     

  • Verified answer
    kpechal150 Profile Picture
    56 on at

    Turns out it was an issue with SQL. I had a trigger on my table for recordupdatedby and recordupdateddate. Deleted the trigger and code ran perfectly. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 522

#2
WarrenBelz Profile Picture

WarrenBelz 437 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 405

Last 30 days Overall leaderboard