SP.UserCustomAction object
Represents a custom action associated with a SharePoint list, Web site, or subsite.
Last modified: March 09, 2015
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.UserCustomAction()
The UserCustomAction object has the following members.
Constructor
The UserCustomAction object has the following constructor.
|
Constructor |
Description |
|---|---|
|
Initializes a new instance of the SP.UserCustomAction object. |
Methods
The UserCustomAction object has the following methods.
|
Method |
Description |
|---|---|
|
Deletes the custom action. |
|
|
|
|
|
Updates the custom action. |
Properties
The UserCustomAction object has the following properties.
|
Property |
Description |
|---|---|
|
Gets or sets a value that specifies an implementation specific XML fragment that determines user interface properties of the custom action. |
|
|
Gets or sets the description of the custom action. |
|
|
Gets or sets a value that specifies an implementation-specific value that determines the position of the custom action in the page. |
|
|
Gets a value that specifies the identifier of the custom action. |
|
|
Gets or sets the URL of the image associated with the custom action. |
|
|
Gets or sets the location of the custom action. |
|
|
Gets or sets the name of the custom action. |
|
|
Gets or sets the value that specifies the identifier of the object associated with the custom action. |
|
|
Gets or sets the value that specifies the type of object associated with the custom action. |
|
|
Gets or sets the value that specifies the permissions needed for the custom action. |
|
|
Gets a value that specifies the scope of the custom action. |
|
|
Gets or sets the value that specifies the ECMAScript to be executed when the custom action is performed. |
|
|
Gets or sets a value that specifies the URI of a file which contains the ECMAScript to execute on the page. |
|
|
Gets or sets the value that specifies an implementation-specific value that determines the order of the custom action that appears on the page. |
|
|
Gets or sets the display title of the custom action. |
|
|
Gets or sets the URL, URI, or ECMAScript (JScript, JavaScript) function associated with the action. |
|
|
Gets a value that specifies an implementation specific version identifier. |
The following example creates an input button on an application page that adds a new menu item to the Site Actions menu of the current Web site.
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <script type="text/ecmascript" language="ecmascript"> function runCode() { var clientContext = new SP.ClientContext(); var site = clientContext.get_web(); var UserCustomActions = site.get_userCustomActions(); var newUserCustomAction = UserCustomActions.add(); newUserCustomAction.set_location('Microsoft.SharePoint.StandardMenu'); newUserCustomAction.set_group('SiteActions'); newUserCustomAction.set_sequence(1000); newUserCustomAction.set_title('New Menu Item'); newUserCustomAction.set_imageUrl('/_layouts/images/myIcon.jpg'); newUserCustomAction.set_description('Menu item added via ECMAScript'); newUserCustomAction.set_url('/_layouts/create.aspx'); newUserCustomAction.update(); clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed)); } function onQuerySucceeded(sender, args) { alert('New menu item added to Site Actions menu.\n\nTo view the new menu item, refresh the page.'); } 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>
See UserCustomAction resource for more information.
Endpoint URI structure
http://<sitecollection>/<site>/_api/web/UserCustomActions(usercustomactionid)
HTTP requests
This resource supports the following HTTP commands:
DELETE syntax
DELETE http://<sitecollection>/<site>/_api/web/UserCustomActions(usercustomactionid)
MERGE syntax
MERGE http://<sitecollection>/<site>/_api/web/UserCustomActions(usercustomactionid)
POST syntax
POST http://<sitecollection>/<site>/_api/web/UserCustomActions(usercustomactionid)
PUT syntax
PUT http://<sitecollection>/<site>/_api/web/UserCustomActions(usercustomactionid)