This documentation is archived and is not being maintained.

SP.FeatureCollection object

SharePoint 2013

Represents a collection of SP.Feature objects.

Last modified: March 09, 2015

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

var object = new SP.FeatureCollection()

The FeatureCollection object has the following members.

Constructor

The FeatureCollection object has the following constructor.

Constructor

Description

FeatureCollection

This member is reserved for internal use and is not intended to be used directly from your code.

Methods

The FeatureCollection object has the following methods.

Method

Description

add

Adds a feature to the collection with the specified feature ID and scope.

getById

Gets the feature with the specified feature ID.

itemAt

Gets the feature at the specified index of the collection.

remove

Removes the feature with the specified ID from the collection.

Properties

The FeatureCollection object has the following properties.

Property

Description

childItemType

item

Gets the feature at the specified index of the collection.

The following example creates an input button on an application page that uses the SP.FeatureCollection collection to display the identifiers (IDs) of the active features on 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>

Endpoint URI structure

http://<sitecollection>/<site>/_api/web/features

HTTP requests

This resource supports the following HTTP commands:

GET syntax

GET http://<sitecollection>/<site>/_api/web/features

POST syntax

POST http://<sitecollection>/<site>/_api/web/features
Show: