Hi gang, hope everyone is well.
We are using a canvas app in conjunction with an Azure SQL server and have noticed some intermittent failures when patching changes back into a database row
The rough architecture is that we have a gallery that is populated with data from a filtered SQL data source added to the app.
We have a button that initially allows us to add rows to this real time and this seems to work without issue. This simply uses the below type of approach but this is obviously redacted.
Patch( SQLDataSource, Defaults(SQLDataSource), {ID: GUID() )
This enters a new row into the DB with a specific GUID as "ID" (to allow us to reference it later, below) and every other data column in that new row will be the SQL defaults. The gallery subsequently refreshes to show this new row.
The issue we are having is when we make edits to this now displayed row in our gallery.
Below is the code that we are using to achieve this, again redacted. This is triggered from an "OnSelect" action from a button in each row.
If(
IsError(
Patch(
SQLDataSource,
LookUp(SQLDataSource,ID=ThisItem.ID),
{
DateFrom: datepickerFromDate.SelectedDate, DateTo: datepickerFromDate.SelectedDate
}
)
),
Notify("Failure"),NotificationType.Error);,
Notify("Success",NotificationType.Success);
I had hoped that using the "IsError" condition along with the patch command, that the query would wait for a response and display "success" or "failure" accordingly but it isn't working that way.
It always displays success yet sometimes, this patch isn't working at all and I don't understand why.
I guess it could be a performance thing but if I could even find a better way to work out if the patch succeeded that would be a start. Any thoughts?
Also, is there a better way for me to update these rows? I had thought patch was a nice and clean way to achieve this but these missed inserts with no record that they have failed is causing me big issues
I know I could create a flow with a sql action to insert/update and call that flow from the app etc but that seems like a huge amount of calls to achieve one simple thing.
Am I missing something?
Appreciate any guidance
J