Damn It, Microsoft (SharePoint)

Came across an interesting quirk today with regards to AddFieldAsXml in the SharePoint API.

It turns out that SharePoint doesn’t really give a damn what you want to call your field when it adds it to the list; it’s going to damn well do whatever it damn well pleases!

You see, in the MSDN documentation, it implies that you can specify the display name and the internal name (just look at that sample code).

However this isn’t the case and, as Bill Simser points out, this has been an issue going back to 2005.

Thankfully, as commenter Morten Bundgaard Pedersen points out, you can use the SPAddFieldOptions.AddFieldInternalNameHint option to force SharePoint to use the name value that you specify in the XML.

Seems kind of silly to me given that this is the most likely use case and should be enabled by default given that the intent — in specifying the Name and StaticName fields would be to, you know, use them when creating the field.

Damn it, Microsoft.

You may also like...