Fix: Network Error When Using the Patch Function in Power Apps
Check if the columns in SharePoint have correct values
4 min. read
Published on
Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more
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
- Verify that each record’s Mail column has a value.
- 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
- Check if any columns in your SharePoint list are set as required/mandatory.
- Make sure you’re passing a value to each mandatory column using the Patch function.
- 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
- Open Power Apps Studio.
- Go to Settings > Advanced Settings > Monitor.
- Run your app and perform the action that triggers the Patch error.
- 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
- Use variables to store intermediate results for each Patch operation.
- For each Patch:
- First, check if the operation was successful.
- If not, handle the error and avoid further operations.
Here’s an example:
ClearCollect(PatchResults,
ForAll(YourDataCollection,
Patch('YourList', Defaults('YourList'), { Title: ThisRecord.Title })
)
);
If(
IsEmpty(Errors('YourList')),
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
- Open Power Apps Studio.
- Locate theย Dataย tab on the left panel.
- Select your data source (e.g., SharePoint list or SQL table).
- 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
- Open Power Apps Studio and select your form.
- Add a button and set itsย OnSelectย property toย SubmitForm(FormName).
- 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
- Go to your SharePoint site.
- Navigate to the list settings.
- Underย Advanced settings, enableย Allow Management of Content Types.
- 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
- Ensure the data types passed in the Patch function match the expected types in SharePoint.
- 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
- Open Power Apps Studio.
- 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.