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
optionelements from the
selectcontrol 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
IDof the items returned from the REST query.
- Append the matches back into the
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
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
input is unimportant, at least after the page loads.