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.
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...
Example Selected.Value not working -
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?
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
}
)
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.
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:
And updated my OnSelect code of my save button to this:
However, now when I run it it looks like its processing but ultimately gives me this error and no other information:
There's no formula errors but there are some performance errors. Though It wont let me see the entire message!?
So I update my dropdown code to:
And I get same error with no information as to why -
Could this be an issue with SQL and not PowerApps?
Thanks!
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.