Workaround: The length of the string exceeds the value set on

the maxJsonLength property in SharePoint 2013 list forms

I was getting this error when I opened a SharePoint list display/New forms. The error appears when I was doing load/scalability testing of SharePoint list with lot of data. The main list has couple of lookup columns. The size of lookup lists was big (around 20K items in each list which was referenced as lookup in the main list )

When I try to  load New/Display form of main list, a variable called WPQ2FormCtx gets loaded with all lookup lists titles and ID in page view source.

Problem: The WPQ2FormCtx variable exceeds the maxJsonLength property which was set in web.config.  

This context is somehow new in SharePoint 2013 and Office 365. This somehow represents the so called form context with a lot of information. Also included in this WPQ2FormCtx variable is the list schema which we can use without loading any additional information from the list.

ULS Error:

System.InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.   

 at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)    

 at Microsoft.SharePoint.WebControls.ClientFormManager.OnPreRender(EventArgs e)    

 at System.Web.UI.Control.PreRenderRecursiveInternal()    

 at System.Web.UI.Control.PreRenderRecursiveInternal()    

 at System.Web.UI.Control.PreRenderRecursiveInternal()    

 at System.Web.UI.Control.PreRenderRecursiveInternal()    

 at System.Web.UI.Control.PreRenderRecursiveInternal()    

 at System.Web.UI.Control.PreRenderRecursiveInternal()    

 at System.Web.UI.Control.PreRenderRecursiveInternal()    

 at System.Web.UI.Control.PreRenderRecursiveInternal()    

 at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I tried to change the maxJsonLength property in web application web.config file, which does not resolve the issue because this poetry only works if you create your own Serialize object like this.

JavaScriptSerializer serializer = new JavaScriptSerializer();

I had to update list schema <forms> section and add UseLegacyForm=”TRUE” attribute for my new/edit and display forms.  This will stop the auto creation of WPQ2FormCtx variable when you load your form.

<Forms>

</Forms>

More Blogs

Contact us

To begin your digital transformation, get in touch.

We’re pleased to address any inquiries you might have and assist you in selecting the service that best suits your requirements.

Your benefits:
Speak To Us