SharePoint, Technical

How to Add a Field (Site Column) SPI to Visual Studio

When you import a site template into Visual Studio and include the site columns, it will create a “Fields” item with a fancy icon:

image

I was asked earlier how to add a similar SPI to a SharePoint project. I assumed it was under the Add New Item dialog and an installed template, but I was wrong! So if you want to add a field SPI, you can do this:

  1. Add a new item, and choose the Empty Element and name it Fields (you can name it whatever you’d like)
  2. Open the SharePointProjectItem.spdata file that is under the Fields element (if you don’t see the file, click on Show All Files at the top of your project explorer)
  3. Change the Type value from
    Microsoft.VisualStudio.SharePoint.GenericElement
    to
    Microsoft.VisualStudio.SharePoint.FieldAnd change the SupportedDeploymentScopes to “Web, Site”

    image

  4. Save the file
  5. Open and close your project, or unload and reload, and you’ll see the icon

If there’s an easier way, please leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *