Fix: Network Error When Using the Patch Function in Power Apps

Check if the columns in SharePoint have correct values

Reading time icon 4 min. read

Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

How to fix the network error when using the patch function

Encountering a network error when using the Patch function in Power Apps is usually caused by issues with a SharePoint list column that is required, and the Patch function is not passing any value to it, or it’s not doing that with correct data.

How do I fix the network error when using the Patch function?

1. Make sure that the Mail column is populated

  1. Verify that each record’s Mail column has a value.
  2. Replace https://<base_site_url>/_layouts/15/UserPhoto.aspx?Size=L&AccountName= & Mail with just an empty string “” for the Picture field.

Ensuring the Mail column is not blank helps SharePoint identify the Person. This solution fixes common data population issues directly related to the Mail column, preventing the error.

2. Validate the required columns

  1. Check if any columns in your SharePoint list are set as required/mandatory.
  2. Make sure you’re passing a value to each mandatory column using the Patch function.
  3. Validate that the data type passed in the Patch function matches the column type (e.g., number for number columns, date for date columns).

This solution addresses issues related to missing or incorrectly typed data, ensuring all required fields are correctly filled and reducing the chances of encountering network errors.

3. Use the Monitor tool

  1. Open Power Apps Studio.
  2. Go to Settings > Advanced Settings > Monitor.
  3. Run your app and perform the action that triggers the Patch error.
  4. Observe and note any detailed error messages or network requests to get more insights into why the operation is failing.

Using the Monitor tool can provide additional insights into the network requests and errors happening behind the scenes, which helps in pinpointing the exact issue causing the error.

4. Handle Multiple Patches Safely

  1. Use variables to store intermediate results for each Patch operation.
  2. For each Patch:
    • First, check if the operation was successful.
    • If not, handle the error and avoid further operations.

Here’s an example:

        Patch('YourList', Defaults('YourList'), { Title: ThisRecord.Title })
    Notify("Patch successful", NotificationType.Success),
    Notify("Patch failed: " & Concat(Errors('YourList'), Column & ": " & Message), NotificationType.Error)

Handling errors in batch operations ensures that you can safely process multiple records and handle failures gracefully without stopping the rest of the operations.

5. Refresh Data Sources

  1. Open Power Apps Studio.
  2. Locate the Data tab on the left panel.
  3. Select your data source (e.g., SharePoint list or SQL table).
  4. Click Refresh to refresh the connection.

This step helps in resolving any stale data connection issues which might be causing the network error during the Patch operation.

6. Use SubmitForm Instead of Patch

  1. Open Power Apps Studio and select your form.
  2. Add a button and set its OnSelect property to SubmitForm(FormName).
  3. Ensure all mandatory fields in the form are filled before submission.

Using SubmitForm can sometimes bypass issues that occur when using Patch, especially with complex forms and mandatory fields, ensuring smoother data operations.

7. Update SharePoint List Settings

  1. Go to your SharePoint site.
  2. Navigate to the list settings.
  3. Under Advanced settings, enable Allow Management of Content Types.
  4. Update the settings for the Title column to remove required status if not needed.

Adjusting list settings and making content types manageable ensures proper alignment of form data with SharePoint list configuration, fixing potential conflicts causing the error.

8. Check Column Types and Constraints

  1. Ensure the data types passed in the Patch function match the expected types in SharePoint.
  2. Verify that there are no list or column validation rules being violated during the Patch operation.

Matching data types and fulfilling validation constraints ensures that your Patch requests are compliant with SharePoint’s schema, reducing the chances of errors.

9. Update Power Apps to Latest Version

  1. Open Power Apps Studio.
  2. Check for updates and move to the latest authoring version by following the instructions in the link Power Apps Studio Versions.

Updating to the latest version resolves any issues related to bugs in earlier versions, ensuring smoother operation of Patch functions.

By following these solutions, you’re tackling common causes of the Patch function’s network error, ensuring your app operates smoothly and efficiently.

Did you manage to fix the problem? Let us know in the comments below.

More about the topics: error, Powerapps