Enable modern document sets programmatically

Some time ago, modern SharePoint sites received a new feature: modern Document Sets. In order to enable and use this feature, “all” you have to do is enable the “Document Sets” feature under Site Collection Features. Then simply add the relevant content type to a library and you can start using them.

Simple right?
Well…perhaps not so simple if you try to do this programmatically.

UPDATE: As per Colin Gardner’s comment below, this issue seems to be fixed now.

All we have to do through the UI is enable a feature, so we expect the same when done programmatically. And here we have multiple options: CSOM, PowerShell, or perhaps a (PnP) provisioning template. But this “not always” works, as reported on GitHub at least here and here.
You can activate the feature and add the content type to the library, but you will get a file not found error for the document sets page (DocSetHome.aspx).

The first GitHub link above contains a workaround by Jlopean.
In summary, if Custom Scripts are not enabled for the site collection, things just don’t work, so ensure that you activate Custom Scripts (on the site collection!) before activating the Document Sets feature and all works fine.

If you looking for different options to enable Custom Scripts, here is a great blog post by Antti K. Koskela.

Many thanks to my colleague Alberto Suarez for helping investigate the issue and update the GitHub issues

3 Replies to “Enable modern document sets programmatically”

Leave a Reply

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