SP.Feature object

Represents an activated feature.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var object = new SP.Feature()

Members

The Feature object has the following members.

Constructor

The Feature object has the following constructor.

Constructor

Description

Feature

Initializes a new instance of the SP.Feature object.

Properties

The Feature object has the following properties.

Property

Description

definitionId

Gets a value that specifies the identifier for this feature.

Example

The following example creates an input button on an application page that displays the identifiers of the active features of the current Web site.

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">

    var featureCollection;
    var oneFeature;

    var site;
    function runCode() {
        var clientContext = new SP.ClientContext();
        site = clientContext.get_web();

        clientContext.load(site);

        featureCollection = site.get_features();
        clientContext.load(featureCollection);

        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    }

    function onQuerySucceeded() {
        var listEnumerator = featureCollection.getEnumerator();
        var featureInfo = '';

        while (listEnumerator.moveNext()) {
            oneFeature = listEnumerator.get_current();
            featureInfo += 'Feature ID: ' + oneFeature.get_definitionId() + '\n';
        }
        alert(featureInfo);
    }

    function onQueryFailed(sender, args) {

        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }

</script>

    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />

</asp:Content>

REST resource endpoint

Endpoint URI structure

http://<sitecollection>/<site>/_api/web/features(featureid)

HTTP requests

This resource supports the following HTTP commands:

POST syntax

POST http://<sitecollection>/<site>/_api/web/features(featureid)