Issue in lookup field when items are too large in lookup list
-
17-01-2021 - |
Pergunta
I have issue in lookup field. When item in lookup field are too large, it throws error "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.".
Is there any solution for that without hiding that column?
I want that field in my new item form but new item form is not opening due to large number of items in lookup field.
I do not want all the lookup items in that field. I just want empty dropdown of that lookup field so i can set value using jslink and lookup field data is saved when i click on Save button.
Thanks
Solução
I used for the similar task:
- Get Lookup Id from query string
<ParameterBinding Name="RootDocId" Location="QueryString(RootDocID)" DefaultValue=""/>
- Replace on NewForm.aspx
<SharePoint:FormField runat="server" id="ff5{$Pos}" ControlMode="New" FieldName="RootDocument" __designer:bind="{ddwrt:DataBind('i',concat('ff5',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@RootDocument')}"/>
with
<asp:TextBox runat="server" id="ff5{$Pos}" text="{$RootDocId}" value="{$RootDocId}" __designer:bind="{ddwrt:DataBind('i',concat('ff5',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@RootDocument')}" />
UPD: To use custom form:
Open NewForm.aspx in Designer
Place cursor just above
<WebPartPages:ListFormWebPart>
tag - the default formFrom "Insert" tab on ribbon use "New Form" button to place it on page
Drop the default form from page.
Outras dicas
You can try increasing maxJsonLength
in the web.config:
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="10000000"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
Why can't the JSon set for the drop down field be emptied or nullified and then assigned, so that the control is empty as expected on loading.
In SharePointDesigner we created 3 forms realted with the list (New, Edit,Display). These forms are the default ones.
Now we can open, edit and create items.