3

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.

enter image description here

Thanks

2
  • Do you want to display this field on new item form? Or just to set value by JS, not user?
    – AlexZh
    Commented May 24, 2018 at 5:26
  • I want empty dropdown in new form. I have all lookup field in separate popup with pagination. so user will select value from popup that will be added to lookup dropdown so when user save it, lookup field value also be saved @Alex Commented May 24, 2018 at 7:29

4 Answers 4

1
+50

I used for the similar task:

  1. Get Lookup Id from query string

<ParameterBinding Name="RootDocId" Location="QueryString(RootDocID)" DefaultValue=""/>

  1. 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')}" />

Building custom forms

UPD: To use custom form:

  1. Open NewForm.aspx in Designer

  2. Place cursor just above <WebPartPages:ListFormWebPart> tag - the default form

  3. From "Insert" tab on ribbon use "New Form" button to place it on page

  4. Drop the default form from page.

8
  • where should i put this code @Alex? Commented May 24, 2018 at 7:33
  • on the new item form (generated by Designer). If you use multiple lookup field, then text value should be "1;#;#2;#;#3;#;#4". You can hide text input and use it in backstage @RajeshJoshi
    – AlexZh
    Commented May 24, 2018 at 7:49
  • My question is when i open new form, there are appox 150k data in lookup field so page is not event loading throw "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property." error before loading page. Commented May 24, 2018 at 7:51
  • Create New Form by Designer. It will generate code with separate fields. Then you can replace lookup column field to text input with binding
    – AlexZh
    Commented May 24, 2018 at 7:53
  • I opened the new form in designer but i cant any find text <SharePoint:FormField Commented May 24, 2018 at 7:56
1

You can try increasing maxJsonLength in the web.config:

<configuration>
 <system.web.extensions>
   <scripting>
    <webServices>
      <jsonSerialization maxJsonLength="10000000"/>
    </webServices>
  </scripting>
 </system.web.extensions>
</configuration>
1
  • I tried that but its not working Commented May 30, 2018 at 4:28
0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.