Set Document Id in SharePoint using JSOM

The example in this topic show how to use JSOM to Set Document Id in SharePoint

  • function SetDocumentId() {
  •  
  •     var clientContext = new SP.ClientContext();
  •     var oWeb = clientContext.get_web();
  •  
  •     clientContext.load(oWeb);
  •  
  •     // Get all the properties
  •     var props = oWeb.get_allProperties();
  •  
  •     // Code to set Document ID of a Site Collection
  •     // Set below key in Site Property bag
  •     props.set_item("docid_msft_hier_siteprefix", "qqqA105678");
  •     oWeb.update();
  •  
  •     clientContext.executeQueryAsync(Function.createDelegate(this, this.onsuccess), Function.createDelegate(this, this.onfailed));
  • }
  •  
  •  
  • function onsuccess() {
  •     console.log("success");
  • }
  •  
  • function onfailed(sender, args) {
  •     console.log('Creation Failed' + args.get_message() + '\n' + args.get_stackTrace());
  • }

Similar examples using different APIs:

Thank you for reading this article. This code was tested in SharePoint 2013

We value your feedback:

Page URL:

Name:

 

Email:

 
 

Feedback:

 

© 2019 Code SharePoint