RAM
RAM

Reputation: 1

Keep getting error "network error when using patch function: the specified record was not found" when using canvas app form - sql on-premise

I have a Canvas app connected to an on-premise SQL Server gateway. The connection is successful, and records can be viewed using the data table preview.

I used a button underneath the data table to navigate to an "Edit" screen that will edit the record selected on the data table (DT). The form preloads with the DT data successfully and everything appears to work correctly. However, when using a button with the SubmitForm(form) function I received the error

Network error when using patch function: the specified record was not found.

With no success, I tried changing the SubmitForm(FormName) function to Patch instead.

Example trying to edit a single field using patch:

Patch(OnPremiseSQLDB,dt_DataTable.Selected,
{Notes: DataCardValue46.Text}); 

Same error.

I have spent well over 2 hours trying to figure out this issue and have been unsuccessful.

I turned on monitoring and received the following logs:

  1. Network - patchRow - Error - Not Found
{
  "status": 404,
  "duration": 74.39,
  "dataSource": "OnPremiseSQLDB",
  "responseSize": 54,
  "controlName": "btn_FormSave",
  "propertyName": "OnSelect",
  "nodeId": 7,
  "formulaData": {
    "script": "Patch(OnPremiseSQLDB,dt_DataTable.Selected,\r\n{Notes: DataCardValue46.Text})",
    "spanStart": 0,
    "spanEnd": 74
  },
  "data": {
    "context": {
      "entityName": "btn_FormSave",
      "propertyName": "OnSelect",
      "id": 13538,
      "nodeId": 7,
      "diagnosticContext": {
        "span": {
          "start": 0,
          "end": 74
        },
        "dataOperation": {
          "protocol": "cdp",
          "operation": "patchRow",
          "apiId": "/providers/microsoft.powerapps/apis/shared_sql",
          "dataSource": "UT_IVCustom",
          "table": "[dbo].[UT_IVCustom]",
          "operationName": "CdpConnector.patchRowAsync"
        },
        "formula": "Patch(OnPremiseSQLDB,dt_DataTable.Selected,\r\n{Notes: DataCardValue46.Text})"
      }
    },

  1. Function - Patch - Error -
{
  "status": null,
  "duration": null,
  "dataSource": null,
  "responseSize": null,
  "controlName": "btn_UT_IVCustomSave",
  "propertyName": "OnSelect",
  "nodeId": 7,
  "formulaData": {
    "script": "Patch(OnPremiseSQLDB,dt_DataTable.Selected,\r\n{Notes: DataCardValue46.Text})",
    "spanStart": 0,
    "spanEnd": 74
  },
  "data": {
    "errorMessage": "Network error when using Patch function: The specified record was not found.",
    "raiseToastNotification": false,
    "wasReported": false,
    "functionName": "Patch",
    "context": {
      "entityName": "btn_FormSavee",
      "propertyName": "OnSelect",
      "id": 13538,
      "nodeId": 7,
      "diagnosticContext": {
        "span": {
          "start": 0,
          "end": 74
        },
        "formula": "Patch(OnPremiseSQLDB,dt_DataTable.Selected,\r\n{Notes: DataCardValue46.Text})"
      }
    },
    "info": "Network error when using Patch function: The specified record was not found."
  }
}

Upvotes: 0

Views: 1734

Answers (1)

Fandango68
Fandango68

Reputation: 4888

You don't have to use ROWVERSION, with Patch() and SQL. Just a primary key and IDENTITY turned ON should be enough.

However, you have to make sure the IDENTITY SEED value is set to the NEXT value, when a new record is created. If the SEED value is lower or set to 1, for example, the Patch() error above can happen.

--Find the next seed ID value and set it
DECLARE @NextIdentityValue INT;
SELECT @NextIdentityValue = IDENT_CURRENT('<<your table>>') + IDENT_INCR('<<your table>>');
DBCC CHECKIDENT ('<<your table>>', RESEED, @NextIdentityValue);

Upvotes: 0

Related Questions