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

A confusing error that can occur is the error "Network error when using Patch" when attempting to save a record by calling the SubmitForm function. This post explains a possible cause of this error.

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.


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.