Skip to content

Latest commit

 

History

History
268 lines (205 loc) · 6.93 KB

Add-PnPCustomAction.md

File metadata and controls

268 lines (205 loc) · 6.93 KB
external help file applicable schema
SharePoint Server 2013, SharePoint Server 2016, SharePoint Online
2.0.0

Add-PnPCustomAction

SYNOPSIS

Adds a custom action

SYNTAX

Client Side Component Id

Add-PnPCustomAction -Name <String>
                    -Title <String>
                    -Location <String>
                    -ClientSideComponentId <GuidPipeBind>
                    [-RegistrationId <String>]
                    [-RegistrationType <UserCustomActionRegistrationType>]
                    [-Scope <CustomActionScope>]
                    [-ClientSideComponentProperties <String>]
                    [-Web <WebPipeBind>]
                    [-Connection <SPOnlineConnection>]

Default

Add-PnPCustomAction -Name <String>
                    -Title <String>
                    -Description <String>
                    -Group <String>
                    -Location <String>
                    [-Sequence <Int>]
                    [-Url <String>]
                    [-ImageUrl <String>]
                    [-CommandUIExtension <String>]
                    [-RegistrationId <String>]
                    [-Rights <PermissionKind[]>]
                    [-RegistrationType <UserCustomActionRegistrationType>]
                    [-Scope <CustomActionScope>]
                    [-Web <WebPipeBind>]
                    [-Connection <SPOnlineConnection>]

DESCRIPTION

Adds a user custom action to a web or sitecollection.

EXAMPLES

------------------EXAMPLE 1------------------

$cUIExtn = "<CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location=""Ribbon.List.Share.Controls._children""><Button Id=""Ribbon.List.Share.GetItemsCountButton"" Alt=""Get list items count"" Sequence=""11"" Command=""Invoke_GetItemsCountButtonRequest"" LabelText=""Get Items Count"" TemplateAlias=""o1"" Image32by32=""_layouts/15/images/placeholder32x32.png"" Image16by16=""_layouts/15/images/placeholder16x16.png"" /></CommandUIDefinition></CommandUIDefinitions><CommandUIHandlers><CommandUIHandler Command=""Invoke_GetItemsCountButtonRequest"" CommandAction=""javascript: alert('Total items in this list: '+ ctx.TotalListItems);"" EnabledScript=""javascript: function checkEnable() { return (true);} checkEnable();""/></CommandUIHandlers></CommandUIExtension>"

Add-PnPCustomAction -Name 'GetItemsCount' -Title 'Invoke GetItemsCount Action' -Description 'Adds custom action to custom list ribbon' -Group 'SiteActions' -Location 'CommandUI.Ribbon' -CommandUIExtension $cUIExtn

Adds a new custom action to the custom list template, and sets the Title, Name and other fields with the specified values. On click it shows the number of items in that list. Notice: escape quotes in CommandUIExtension.

PARAMETERS

-ClientSideComponentId

The Client Side Component Id of the custom action

Type: GuidPipeBind
Parameter Sets: Client Side Component Id

Required: True
Position: Named
Accept pipeline input: False

-ClientSideComponentProperties

The Client Side Component Properties of the custom action. Specify values as a json string : "{Property1 : 'Value1', Property2: 'Value2'}"

Type: String
Parameter Sets: Client Side Component Id

Required: False
Position: Named
Accept pipeline input: False

-CommandUIExtension

XML fragment that determines user interface properties of the custom action

Type: String
Parameter Sets: Default

Required: False
Position: Named
Accept pipeline input: False

-Description

The description of the custom action

Type: String
Parameter Sets: Default

Required: True
Position: Named
Accept pipeline input: False

-Group

The group where this custom action needs to be added like 'SiteActions'

Type: String
Parameter Sets: Default

Required: True
Position: Named
Accept pipeline input: False

-ImageUrl

The URL of the image associated with the custom action

Type: String
Parameter Sets: Default

Required: False
Position: Named
Accept pipeline input: False

-Location

The actual location where this custom action need to be added like 'CommandUI.Ribbon'

Type: String
Parameter Sets: Default

Required: True
Position: Named
Accept pipeline input: False

-Name

The name of the custom action

Type: String
Parameter Sets: Default

Required: True
Position: Named
Accept pipeline input: False

-RegistrationId

The identifier of the object associated with the custom action.

Type: String
Parameter Sets: Default

Required: False
Position: Named
Accept pipeline input: False

-RegistrationType

Specifies the type of object associated with the custom action

Type: UserCustomActionRegistrationType
Parameter Sets: Default

Required: False
Position: Named
Accept pipeline input: False

-Rights

A string array that contain the permissions needed for the custom action

Type: PermissionKind[]
Parameter Sets: Default

Required: False
Position: Named
Accept pipeline input: False

-Scope

The scope of the CustomAction to add to. Either Web or Site; defaults to Web. 'All' is not valid for this command.

Type: CustomActionScope
Parameter Sets: Default

Required: False
Position: Named
Accept pipeline input: False

-Sequence

Sequence of this CustomAction being injected. Use when you have a specific sequence with which to have multiple CustomActions being added to the page.

Type: Int
Parameter Sets: Default

Required: False
Position: Named
Accept pipeline input: False

-Title

The title of the custom action

Type: String
Parameter Sets: Default

Required: True
Position: Named
Accept pipeline input: False

-Url

The URL, URI or ECMAScript (JScript, JavaScript) function associated with the action

Type: String
Parameter Sets: Default

Required: False
Position: Named
Accept pipeline input: False

-Connection

Optional connection to be used by cmdlet. Retrieve the value for this parameter by eiter specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type: SPOnlineConnection
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: False

-Web

This parameter allows you to optionally apply the cmdlet action to a subweb within the current web. In most situations this parameter is not required and you can connect to the subweb using Connect-PnPOnline instead. Specify the GUID, server relative url (i.e. /sites/team1) or web instance of the web to apply the command to. Omit this parameter to use the current web.

Type: WebPipeBind
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: False

RELATED LINKS

SharePoint Developer Patterns and PracticesUserCustomActionBasePermissions