I wound up modifying the source from a publically posted POC: http://datacogs.com/datablogs/archive/2007/08/26/641.aspx, which is a custom field definition for cascading drop downs. The modifications were to allow parent-child list boxes where a user can multiselect for filtering and selecting the values to be written back to a SharePoint list. I got the parent-child cascading behavior working, but the save operation only takes the first value that is selected from the list box. I changed the base type for the custom field control from "SPFieldText" to "SPMultiLineText", along with changing the FLD_TYPES field definition values from:
Text to Note and this did not work. So, I changed the field control base type to "SPFieldMultiChoice" and the FLD_TYPES to "MultiChoice" and still get the same result, which is only the first value that's selected, writing to the SharePoint list.
Does anyone have any idea how to get a custom field with multiple selections to write those multiple selections to a SharePoint list?
Thanks for taking the time to read through my post.
Cheers,
~Peter
Best Answer
I was able to accomplish this by inheriting from
SPFieldLookup
and overriding its internal handling ofAllowMultipleValues
:In your FLDTYPES_*.xml set
<ParentType>LookupMulti</ParentType>
In your extension of
SPFieldLookup
, be sure to overrideAllowMultipleValues
(alwaystrue
),FieldValueType
(probablytypeof(SPFieldLookupValueCollection)
) andFieldRenderingControl
. I also setbase.LookupField = "LinkTitleNoMenu"
, though in retrospect I'm not sure why. :)In your field editor control's
OnSaveChange()
, set the field'sMult
value totrue
.To set
Mult
, you can either string manipulation onfield.SchemaXml
:Or use reflection:
It's been a while, so I might be forgetting something, but that should be most of it.