Question

See Can site columns be deployed in sandboxed solutions? for background on this.

I've tried to reproduce the sandboxed feature with a site column as built by Hilton Giesenow shown on How Do I: Create a Site Column in Visual Studio 2010. When I used a content type project like he did, it worked as he shows. However, if I start with an empty sharepoint project and add an empty element file (which creates a feature much like he shows in his video), it doesn't work.

I opened up the resulting WSPs and compared the XML. What I found was that the packages were identical with the exception of the GloballyAvailable property set to "True" on the feature built in the content type project like Giesenow did. I added that property to my feature, rebuilt the packages, and compared the resulting XML and found no differences other than feature names/IDs. I redacted some of the naming to keep a client anonymous.

Comparison of WSP files

Now what? Why does one work and not the other?

I found an article that made me think that ensuring the name of the empty element matched the Field element's name attribute would do the trick:

The Name attribute of the WebTemplate element will have to exactly the same as the name of your Empty Element in Visual Studio. If these two don’t match the web template won’t deploy properly.

I renamed the element node in my project to "OrderIndex" to match the name of my site column, and that didn't work either.

Update: after doing some more looking, I found Walkthrough: Create a Custom Field, Content Type, List Definition, and List Instance on MSDN. I pretty much followed exactly the directions in the "Custom Field" section.

Was it helpful?

Solution

Finally found the answer, which is summed up neatly by Phil Harding in SharePoint Integer and Numeric Field (Site Column) Types.

Bottom line: it was working all along, just not visible in the Site Column Gallery (which means it could only be used in content types, not in UI-built custom lists). If you want it to show up in the gallery, you have to use a type marked with UserCreatable = TRUE.

My column still isn't in the Gallery, but here's what PowerShell has to say about it:

PS C:\Users\Administrator> $site.RootWeb.Fields |? {$_.Group -eq "XXXX"} | ft InternalName,Type

InternalName                 Type
------------                 ----
OrderIndex                   Integer
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top