Geeks With Blogs
Michael Waites

I have a site that needs to be deployed programmatically. It has multiple challenges. One challenge is that the site has columns, custom types, and lookup list. The issue is that the lookup list make use of a custom content type and other content types use the lookup list. This challenge makes it difficult to completely deployable from a feature.

Another issue is that the client wants to make use of a document information panel, DIP.

The problem I had… is when I tried to make a new DIP template, Info path would report a catastrophic failure. That’s it. That is the only error I could go on was an ambiguous catastrophic failure.

I finally found the problem. SharePoint HATES spaces!

<Field DisplayName="Test Name"
                Type="Text"
                Required="TRUE"
                MaxLength="50"
                Group="TestGroup"
                ID="{71519466-C336-49fb-8617-5A82100B9038}"
                SourceID="http://schemas.microsoft.com/sharepoint/v3"
                StaticName="Test Name"
                Name="Test Name">
                                <Default>Test</Default>
</Field>

 

This is a typical schema for a column named ‘Test Name’. If you use this scheme, especially if you load it via “currentWeb.Fields.AddFieldAsXml” you will find that SharePoint will be happy to use it. Later if you address this field (e.g. Fields[“Test Name”]) it will work fine.

HOWEVER, SharePoint does not like spaces and sometimes will want to put _x0020_ in place of spaces. But because I loaded them via AddFieldAsXml method, SharePoint left the spaces in.

INFOPATH hates spaces even more. Because I have columns with spaces when trying to create the DIP I get a catastrophic failures. To fix this issue, we can substitute _x0020_ for spaces in the StaticName and Name attributes, or do as I did, just remove them completely. Again, leave the spaces in the display name, that’s fine, just remove them from the StaticName and Name.

<Field DisplayName="Test Name"
                Type="Text"
                Required="TRUE"
                MaxLength="50"
                Group="TestGroup"
                ID="{71519466-C336-49fb-8617-5A82100B9038}"
                SourceID="http://schemas.microsoft.com/sharepoint/v3"
                StaticName="TestName"
                Name="TestName">
                                <Default>Test</Default>
</Field>

 

 

Posted on Tuesday, April 14, 2009 8:55 AM | Back to top


Comments on this post: Spaces in SharePoint Fields

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © mwaites | Powered by: GeeksWithBlogs.net