July 6, 2012

Defining a Lookup Field with Multiple Values

Anyone who's spent about five minutes with SharePoint knows it can be pretty quirky. As a developer, some of the odd things we run into can be downright maddening! I ran into one of these types of issues today but was luckily saved by another community member.

I'm working on a feature which contains two lists, where List B contains a lookup column which should allow the user to select multiple values from List A. While testing I found that although the edit page allowed me to select multiple values for this column, only the first selected value was actually being saved. Weird! I went back to verify that my field definition was correct and here's what it looked like:
Looks good, right? Right. IT LOOKS PERFECTLY CORRECT. But SharePoint is SharePoint, and so after a quick Google search brought me to this page I was able to find the problem: the Mult attribute is randomly and inexplicably case-sensitive. So while my value of "True" looks fine and dandy, my solution will not work as expected. The value must be "TRUE" in order to fix the problem. Unbelievable!
My solution actually had this attribute in my list definition's schema.xml file as well as on the field definition itself, and so I needed to change it in both places. Be warned!

No comments:

Post a Comment