12

What is the best practice for creating a site column or content type in SharePoint 2013? Is it still recommended to use farm solutions? I was hoping we could do something with the new app model, but that appears to only allow site level features.

A little more background. Each developer has their own dev instance of SharePoint 2013. We also have a shared QA/UAT instance. And finally, there is the customer production environment.

I'm trying to get a Continuous Integration workflow setup, so that each developer commits their work to TFS, we can run an automated build that updates the QA/UAT instance. Once that is approved, I want to be able to give the customer a deployment package that they run in their environment.

I come from a ASP.NET background and I know how to do this there, but I'm unsure how to accomplish this with SharePoint.

7

Solution Packages - whether Farm or Sandbox - are still the way to go for deploying site columns and Content Types. With an "app", you can only deploy these artifacts to the app itself, not to the host SharePoint site (and I'm a little peeved with Microsoft for not making it more clear what you can and can't do in an app).

And yes, Sandbox solutions are deprecated technically in 2013, but they are not going anywhere, and they are still the only way to deploy code to SharePoint Online.

As far as your automated build is concerned, you should be able to accomplish what you are trying. One thing you should keep in mind though is that redeploying to UAT will necessitate deleting and re-creating your lists and libraries (and associated data).

  • You CAN provision Site Columns and Content Types via SharePoint apps using JSOM. Re. my answer below – Andrey May 3 '13 at 21:03
  • this is obsolete and also deprecated means: do not use it for new solutions. That is actually bad practice in my opinion. Even at the time you wrote that answere, there was already a way to do it (PS, CSOM, JSOM). It needed just more effort, but resued, you only need to do it once. – Sebastian Schütze Feb 3 '17 at 11:48
  • Sebastian, you are absolutely right. – Derek Gusoff Feb 4 '17 at 3:52
6

From SP2010 and forward we have not used solutions / features for this. Instead we use PowerShell to do this programmatically using server side API's.

By doing this we avoid "unghosting" the content types (as doing it declaratively does) and we also avoid having to deploy a package which include resetting IIS.

In SP2013 we continue doing this, but since we want to do this for our cloud solutions as well as on-premises solutions, we have converted our scripts to ClientSide Object Model (CSOM).

The one disadvantage of doing this is, that Microsoft unfortunately haven't supplied us with the possibility of deciding the Content Type ID as we can server side. This makes provisioning across platforms harder since we dont know the ID. It can be circumvented somewhat -for example in search you can use the CT name instead of the ID in queries.

  • Now it is possible since some time to choose your own content type ID. so that shouldn't be the problem anymore. – Sebastian Schütze Feb 3 '17 at 11:50
1

You can provision Site Columns and Content types via SharePoint Apps as described here: http://www.eliostruyf.com/provisioning-site-columns-and-content-types-via-a-sharepoint-app/

1

As time passes. The correct flagged answer is mostly obsolete in my opinion. The way to go these days, is remote provisioning with the client side object model (CSOM) or with JavaScript.

Sandboxed solutions are deprecated and that means, that there are solely there for backwards comaptiblity. If you want to have a clean solution consider doing one of the following things (solutions are cloud first, this means they should work online and on premise) :

  • provisioning within the SharePoint app
  • provisioning with powershell

you just have one problem: you need to code the code yourself. And when using powershell you need to use CSOM and do some kind of half C# and half PowerShell within the scripts.

But there is a great framework, which is the PnP Provisioning Framework, which allows you to use JS, PowerShell or C# to privision your content with very little effort compared to just use JSOM or CSOM.

Have a look here for the PnP PF:

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.