We faced a scenario where we need to update the prefix for document Id settings for more numbers of site collection in SharePoint Site through code. After some investigation, I figured out the code and thought of sharing it. Here is the code:
Using C# code
- Add the following references.
- Microsoft.SharePoint.dll
- Microsoft.Office.DocumentManagement.dll
- Add the following namespaces.
- Using Microsoft.SharePoint;
- Using Microsoft.Office.DocumentManagement;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Microsoft.SharePoint;
- using Microsoft.Office.DocumentManagement;
- namespace ConsoleAppChangeDocPrefix
- {
- class Program
- {
- static void Main(string[] args)
- {
- SPSite site = new SPSite("http://serverName:2085/");
- DocumentId.SetDefaultProvider(site);
- DocumentId.EnableAssignment(site, "sivaprefix", true, true, true, false);
- site.Dispose();
- }
- }
- }
Reference : https://msdn.microsoft.com/EN-US/library/office/ee580557.aspx