I find this article which describe how i need to create site columns programmatically using visual studio https://msdn.microsoft.com/en-us/library/ee231593.aspx.

they mentioned that I should use the "default value Deploy as a sandboxed solution". so my question is that what will be the differences if i use sandboxed solution or a farm solution to add custom site columns ?

second question. in general if i add new site columns using visual studio , this will generates a site feature . but what will happen if i "deactivate" the generated feature ? will this cause the site columns to be deleted ? if the answer is yes,, so if i have a list or content type that reference these columns will i be able to deactivate the feature ?


If you limit the scope to the MSDN Walkthrough you linked, there is only one difference between Farm and Sandbox Solutions that is important. You could deploy the Sandbox Solution to SharePoint Online but not the Farm Solution.

It's been a while since I looked at this but I'm 80% certain that when you deactivate the Feature, a site column created using CAML (XML) will go away. That is if the site column is not part of any list or content type.

Once a site column is in use it can't be removed and, if I recall correctly, the Feature that provisioned the site column cannot be deactivated.

  • now i am not using SharePoint online, so in my case i have on-premise SharePoint server, so what will be the main differences if i create site column using Farm or Sandbox solution? – john Gu Jul 18 '15 at 1:48
  • There are no major differences if you are creating the site column using XML – Rob Windsor Jul 18 '15 at 10:55

In my experience, the only time you may want to use a Farm Solution instead of a Sandbox solution is if you have some site columns that are Managed Metadata or Lookup columns. The declarative syntax in your solution will only created the column, but in the case of a Managed Metadata column you will still need to connect it to a term set, and in the case of a Lookup column you will need to connect it to a list. If you are using a Farm Solution you could do this with a Feature Receiver, however if you are using a Sandbox solution you will need to do this outside of your solution (e.g. manually, PowerShell, console App).

Deactivating the feature will only delete content types and site columns if there is no content using the content type or the site column. Otherwise, deactivating the feature will delete the site columns and content types. Either way you can deactivate the feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.