Enabling The Developer Site Collection Feature SharePoint Online Office 365 -CSOM

This blog will help you to enable the development feature in SharePoint 2013, using JSOM.
In SharePoint 2013, we have a new site template called Developer Site Template. It is a site template, which is used extensively for app development and you can only deploy apps for SharePoint to a Developer Site.

I have a scenario, where I need to enable the Developer Site Collection feature for an existing Site Collection, which may be a team site or publishing site. There isn't a button in Site Collection features which allows you to enable this.

If you were on SharePoint 2013 On-Premises, you’d just run Enable-SPFeature, which is shown below.
  1. Enable-SPFeature e374875e-06b6-11e0-b0fa-57f5dfd72085 –url http://gowthamr.sharepoint.com  
With SharePoint Online, we can't do this directly, so I have created a simple method to solve this. We can run this script in our Internet Browser console.
  1. <script>  
  2. $(document).ready(function () {  
  3.   
  4. var featureID="e374875e-06b6-11e0-b0fa-57f5dfd72085";  
  5. ActivateFeature(featureID);  
  6.   
  7. });  
  8.   
  9. function ActivateFeature(featureGuid)  
  10. {  
  11. var clientContext = new SP.ClientContext.get_current();  
  12. var site = clientContext.get_site();  
  13. var guid = new SP.Guid('{'+featureGuid+'}');  
  14.   
  15. var featDef = site.get_features().add(guid, false, SP.FeatureDefinitionScope.site);  
  16.   
  17. clientContext.executeQueryAsync(Function.createDelegate(thisthis.OnSuccess), Function.createDelegate(thisthis.OnFail));  
  18. }  
  19.   
  20. function OnSuccess(sender, args) {  
  21.     alert('Successfully enabled Developement feature!');  
  22. }  
  23.   
  24. function OnFail(sender, args) {  
  25.     alert('Fail: ' + args.get_message() + '\n' + args.get_stackTrace());  
  26. }  
  27.   
  28. </script>  
Was my blog helpful?

If so, please let me know at the bottom of this page. If not, let me know what was confusing or missing and I’ll use your feedback to double-check the facts, add info and update this blog.
Ebook Download
View all
Learn
View all