SP.RecycleBinItem object

Represents a Recycle Bin item in the Recycle Bin of a site or a site collection.

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

var object = new SP.RecycleBinItem()

Members

The RecycleBinItem object has the following members.

Constructor

The RecycleBinItem object has the following constructor.

Constructor

Description

RecycleBinItem

Initializes a new instance of the SP.RecycleBinItem object.

Methods

The RecycleBinItem object has the following methods.

Method

Description

deleteObject

Permanently deletes the Recycle Bin item.

initPropertiesFromJson

restore

Restores the Recycle Bin item to its original location.

Properties

The RecycleBinItem object has the following properties.

Property

Description

author

Gets a value that specifies the user who created the Recycle Bin item.

deletedBy

Gets a value that specifies the user who deleted the Recycle Bin item.

deletedDate

Gets a value that specifies when the Recycle Bin item was moved to the Recycle Bin.

dirName

Gets a value that specifies the site relative URL of the list or folder that originally contained the Recycle Bin item.

id

Gets a value that specifies the identifier of the Recycle Bin item.

itemState

Gets a value that specifies the Recycle Bin stage of the Recycle Bin item.

itemType

Gets a value that specifies the type of the Recycle Bin item.

leafName

Gets a value that specifies the leaf name of the Recycle Bin item.

size

Gets a value that specifies the size of the Recycle Bin item in bytes.

title

Gets a value that specifies the title of the Recycle Bin item.

Example

The following example creates an input button on an application page that displays the title and Id of the first item in the Recycle Bin of the current site.

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

    var recycleItemCollection;
    function runCode() {
        var clientContext = new SP.ClientContext.get_current();
        if (clientContext != undefined && clientContext != null) {
            var site = clientContext.get_site();
            this.recycleItemCollection = site.get_recycleBin();

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

    function onQuerySucceeded() {
        if (this.recycleItemCollection.get_count() > 0) {
            var item = this.recycleItemCollection.itemAt(0);
            var id = item.get_id();
            var title = item.get_title();
            alert('Title: ' + title + '\n' + 'Item ID: ' + id + '\n');
        }
        Else {
            alert("The Recycle Bin is empty."
        }
    }

    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/RecycleBin(recyclebinitemid)

HTTP requests

This resource supports the following HTTP commands:

DELETE syntax

DELETE http://<sitecollection>/<site>/_api/web/RecycleBin(recyclebinitemid)

POST syntax

POST http://<sitecollection>/<site>/_api/web/RecycleBin(recyclebinitemid)