1

I have to filter the available options for a multi-lookup field based on the value of a Taxonomy field. I had it working in 2013 doing this:

  • On page load, detach all the option elements from the _SelectCandidate select control and store them in an array.
  • Once the Term has been selected, make a REST query to the lookup list to return all items that are tagged with the same Term.
  • Filter through the array of all options and return the ones whose value matches an ID of the items returned from the REST query.
  • Append the matches back into the _SelectCandidate select control.

This worked fine, even for Editing, because any selected options would be in the _SelectResult control and therefore wouldn't be in the candidate options that got filtered according to the REST query results, and the Add and Remove buttons seemed to just pop the options back and forth between the selects.

But in SP 2016, if I go to remove one of the previously selected options, not only does that option move back to the candidate select, but also, all of the original options that should have been filtered out reappear.

I poked around in the HTML and I saw that there was a hidden input field with an ID that ended in _data that seemed to have an encoded version of what all the options would be.

So, I tried modifying that to only have the filtered options that I wanted to count as "all valid candidates". However, even after doing that, when trying to remove a selected option, the candidate box still gets repopulated with all the options, including the ones I want filtered out, so it seems that the value of that hidden _data input is unimportant, at least after the page loads.

So is the multi-lookup control now being controlled by some extra Javascript somewhere, that's maybe caching it's own version of "all the valid candidates"? How can I hijack that to make sure my filtering is applied correctly?

Your Answer

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

Browse other questions tagged or ask your own question.