After getting frustrated by dropdowns not even rendering for the lists with more than 5000 items, I take on a journey.

Idea is using a cascaded dropdown to keep item count to be populated under 5000. Since SharePoint does not even create the dropbox in this case, I decided to create it from scratch, where the error message is displayed using a select statement like

<select id="Primary_x0020_Contact_1bc5bbf8-a68b-48a0-a2e8-8f67c83da0c6_$LookupField" title="Primary Contact">

I looked up field ID manually using this method.

Dropdown gets created nicely and I populated it using an Ajax query with relevant ID/Value pairs.

Problem is that, when I submit the form, it does not get saved.

Is there another magic, other than using the correct field ID that I need to add to the mix ?

  • You have to bind the drop down selection to your list column. Randomly adding html to your form does nothing unless you set the value in the corresponding field. Dec 16 '16 at 15:58
  • Thank you Eric. Is this something I can do within my JavaScript ? I've been searching but couldn't find many references. I appreciate if you can point me in the right direction.
    – Charles
    Dec 16 '16 at 16:09
  • Yes, you'd incorporate a change function on your html field, that when selected, it sets the value in the appropriate column. You'd also need to create a function that reads the current list value and sets that as the value in your dropdown on load if the sharepoint field value exists for completeness. Dec 16 '16 at 16:13
  • Got it, on load I am getting current value, which is fine. My question then is, if I change the actual column value using change function, what happens if the users clicks "Cancel" in the end ? Is there no way to bind this field so that it gets processed together with other fields when user clicks "Submit"? Thanks again.
    – Charles
    Dec 16 '16 at 16:17
  • the default sharepoint behavior kicks in, if you change a field value in the edit form and click cancel, nothing is changed because the form isn't saved/submitted. Dec 16 '16 at 16:29

The way this typically goes is that on the edit form, you hide the default field in which you plan to replace with your desired html code. On page load, you have to read the current value of the default list field and set your custom drop down to that value if it exists. You add the remaining lookup values to your custom drop down.

Then, you need a change function on your custom drop down that sets the hidden default list form field value to the selected value, i.e $("input[title='Title']").val(YourSelectedValue). When the user clicks the default save button, the list item is updated. If the user selected a value in the custom drop down but cancels out, nothing happens.

You don't need any other submission code or anything like that, SharePoint will do that for you so long as you update the value of the desired field when your custom drop down field is altered.

  • Eric, thank you for the answer. But as I mentioned, the problem here is that there is no default field to hide (or update later). Challenge is when a dropbox is for a lookup field from a list with more than 5000 items it does not even placed on the page, instead just a <span> with the error message. Hence I tried to recreate the component. Following on from your advice, I tried to update actual SharePoint field using PreSaveItem function, but this causes a conflict with the default save action. Also tried taking over Save button and processing it later but I still get conflict.
    – Charles
    Dec 17 '16 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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