Error - Diagnosing the error "Network error when using the Patch function" when saving data with a form

When saving data with forms, there may be the odd occasion where a form randomly fails to save.

It can be difficult to diagnose this type of error and this post describes one cause of this error. 

Recreating the Network error when calling Patch error

To recreate this problem, I've created a sample Dataverse app with co-pilot. The app is a bookmarking app that stores web addresses.

When running the app, saving a record can occasionally give the error "Cannot save. Please check if there are errors in the form".



When reviewing the error in the designer, we see the more precise error "Network error when using Patch function: The requested operation is invalid".


This is a generic error message that occurs when saving data. It's particularly confusing since it occurs when calling SubmitForm rather than the Patch function.

Unfortunately, the Montor tool doesn't provide any further detail that explains why the record fails to save.

Check the data that's being saved

When records fail to save intermittently, one of the first things to check is the data that we're attempting to save.

With some trial and error, it soon becomes apparent that the length of the data contributes to the error. The record fails to save when long URLs are entered.

On investigating the properties of the field in the Dataverse table designer, it's apparent that the "maximum character count" is set to the default of 250. The app doesn't correctly enforce this 250-character limit and when the user attempts to save a record that exceeds this limit, Power Apps doesn't return a meaningful message that indicates the cause.     



The interesting thing is that the failure to enforce the maximum character count applies only to the enhanced Dataverse text types, such as URL. In this example, increasing the maximum character count resolves the problem.

Conclusion

When intermittent errors occur when saving records, the first thing to check is the length of the data that's being saved. There is a bug with Power Apps not enforcing the maximum character count for enhanced text types, so that can be a cause of the error.

Related posts

Dataverse - How to set yes no values with checkbox- Walkthrough
January 29, 2025
Dataverse - Add image column missing when creating table - how to fix
January 19, 2025
Data - How to view the progress and status of a Dataverse CSV/Excel Import
January 15, 2025
Dataverse - How to work around the error "multiple levels of many-to-one relationship expansion aren't supported"
April 05, 2024
Dataverse - The easiest way to modify Dataverse data outside of Dataverse and Power Apps
February 18, 2024
Dataverse - How to use a checkbox control a set a yes/no field in Dataverse
July 10, 2023
Dataverse - How to create Entity Relationship diagrams
January 22, 2023
Dataverse - How you can more quickly bulk update data using the SQL language
January 14, 2023
Dataverse - How to fix the bug in the 'Business Rules' editor that prevents numeric values from saving
January 05, 2023
Dataverse - What are the benefits, and how to create formula columns
July 20, 2022
Dataverse - How to sort the available choice items from a choice column
May 12, 2022
Error - Unable to modify Dataverse tables with error message, Language id should not be null
September 27, 2021
Dataverse - How to retrieve FetchXML or SQL for Dataverse views
July 13, 2021
Data - Why is Dataverse so fast?
June 15, 2021
Dataverse - How to create and use Dataverse views in Canvas Apps
June 09, 2021
Dataverse - How to filter Dataverse choice columns
June 07, 2021
Dataverse - How to switch to the classic designer when the option is not available
May 26, 2021
Licensing - What are Dataverse Restricted tables?
March 26, 2021
Media - How to save and work with microphone recordings
March 09, 2021
Dataverse - how to access tables from another environment
February 23, 2021
Dataverse - How to Patch the 5 most complex data types
January 19, 2021