SP.UsageInfo object
Provides fields that are used to access information about site collection usage.
Last modified: March 09, 2015
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.UsageInfo()
The UsageInfo object has the following members.
Constructor
The UsageInfo object has the following constructor.
|
Constructor |
Description |
|---|---|
|
Initializes a new instance of the SP.UsageInfo object. |
Properties
The UsageInfo object has the following properties.
|
Property |
Description |
|---|---|
|
Gets a value that specifies the cumulative bandwidth, in bytes, used by the site collection during an implementation specific period. |
|
|
Gets a value that specifies the total amount of disk space, in bytes, currently being used to store Web discussion comments in the site collection. |
|
|
Gets a value that specifies the cumulative number of requests for pages in the site collection during an implementation specific period. |
|
|
Gets a value that specifies the total amount of disk space, in bytes, currently being used by the site collection. |
|
|
Gets a value that specifies the ratio of the amount of disk space currently being used by the site collection to the maximum disk space specified in the site collection quota. |
|
|
This member is reserved for internal use and is not intended to be used directly from your code. |
|
|
Gets a value that specifies the cumulative number of requests for pages in the site collection, with no referring URL, or a referring URL outside of the current site collection during an implementation specific period. |
The following example creates an input button on an application page that displays usage information about the current site.
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <script type="text/ecmascript" language="ecmascript"> var usageInfo; var site; var clientContext; function runCode() { this.clientContext = new SP.ClientContext.get_current(); if (this.clientContext != undefined && this.clientContext != null) { this.site = clientContext.get_site(); this.clientContext.load(this.site, 'Usage'); this.clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed)); } } function onQuerySucceeded() { this.usageInfo = this.site.get_usage(); var info = 'Storage: ' + this.usageInfo.get_storage() + '\nStorage percentage: ' + this.usageInfo.get_storagePercentageUsed() + '\nVisits: ' + this.usageInfo.get_visits(); alert(info); } 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>