[O365] Enable document ID and set prefix via CSOM

Ok, I agree I’m late to the party introducing the [O365] tag in the title of this post. And I’ve got quite some blogposts already which also apply to Office 365. But to emphasize there is little difference in using CSOM either on premises or online, I thought this would be a good time to switch. And mentioning you’re doing Office 365 project is all hip and happening anyway, so here it is.

This simple post gives you some code which shows how to set the Document ID settings via CSOM. It’s not hard, but since I haven’t been able to find any blogs out there which cover this, I thought I’d take the opportunity.

You’ll find that the client side object models do not give you a way of directly changing settings related to the Document ID feature. In particular, this window in your site settings (Site Collection Administration => Document ID Settings):

documentid

 

Well, as with most of the settings you cannot find in the object model, they are actually stored in the property bag of your site collection. This blog gives an overview of the properties there are, and if you want to find out which properties are on your sites, you can use the SharePoint Client Browser project by Bram de Jager for that.

The properties you’ll want to set are:

  • docid_enabled; the “Assign Document IDs” checkbox
  • docid_msft_hier_siteprefix; the prefix you set for the document ID feature

And with that knowledge, setting them is easy:

Leave a Reply

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