I have created a multicolumn custom field and deployed it in SharePoint. To be able to use the field values from my custom field I also deployed an event receiver to copy the three values from my custom field to three separate regular text fields. If the three text fields do not exist I create them with XML in code. I also make sure the fields have the right visibility settings even if the field exist.
Creating the field in xml:
string fieldXml = string.Format("<Field ID=\"{0}\" " +
                                    "Type=\"{1}\" " +
                                    "Name=\"{2}\" " +
                                    "StaticName=\"{2}\" " +
                                    "DisplayName=\"{2}\" " +
                                    "Required=\"{3}\" " +
                                    "ShowInEditForm=\"TRUE\" " +
                                    "ShowInNewForm=\"TRUE\" " +
                                    "ShowInDisplayForm=\"TRUE\" " +
                                    "ShowInListSettings=\"TRUE\" " +
                                    "ShowInViewForms=\"TRUE\" " +
                                    "ShowInVersionHistory=\"TRUE\" " +
                                    "ShowInFileDlg=\"TRUE\"" +
                                    "></Field>",
                                    Guid.NewGuid(),
                                    fieldType,
                                    fieldName,
                                    required);
list.Fields.AddFieldAsXml(fieldXml, true, SPAddFieldOptions.Default);
Make sure visibility settings OK when the field already exist:
field.ShowInEditForm = true;
field.ShowInNewForm = true;
field.ShowInDisplayForm = true;
field.ShowInListSettings = true;
field.ShowInViewForms = true;
field.ShowInVersionHistory = true;
field.Update();
list.Update();
I found no way of setting the ShowInFileDlg property programmatically once the field was created.
The thing is that this code works great up until I open a document in MS Word and the three text fields all have text assigned in the list but in Word they are empty!
Have anybody seen this before, what am I doing wrong!?