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.
- Enable-SPFeature e374875e-06b6-11e0-b0fa-57f5dfd72085 –url http:
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.
- <script>
- $(document).ready(function () {
-
- var featureID="e374875e-06b6-11e0-b0fa-57f5dfd72085";
- ActivateFeature(featureID);
-
- });
-
- function ActivateFeature(featureGuid)
- {
- var clientContext = new SP.ClientContext.get_current();
- var site = clientContext.get_site();
- var guid = new SP.Guid('{'+featureGuid+'}');
-
- var featDef = site.get_features().add(guid, false, SP.FeatureDefinitionScope.site);
-
- clientContext.executeQueryAsync(Function.createDelegate(this, this.OnSuccess), Function.createDelegate(this, this.OnFail));
- }
-
- function OnSuccess(sender, args) {
- alert('Successfully enabled Developement feature!');
- }
-
- function OnFail(sender, args) {
- alert('Fail: ' + args.get_message() + '\n' + args.get_stackTrace());
- }
-
- </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.