SharePoint: SPFieldCollection.AddFieldAsXml Gotcha


This one caught me out today;

The SPFieldCollection.AddFieldAsXml method has a strange quirk – the field is created using the DisplayName value as the fields internal name (InternalName), instead of using the Name/StaticName value.

See this post for further information and a workaround.

Published by

Phil Harding

SharePoint Consultant, Developer, Father, Husband and Climber.

2 thoughts on “SharePoint: SPFieldCollection.AddFieldAsXml Gotcha

  1. The powershell version of AddFieldAsXml run against SharePoint 2007 does not exhibit this bug.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.