Skip to content

Instantly share code, notes, and snippets.

@rjesh-git
Created October 31, 2015 15:50
Show Gist options
  • Save rjesh-git/72de83ac92273749f782 to your computer and use it in GitHub Desktop.
Save rjesh-git/72de83ac92273749f782 to your computer and use it in GitHub Desktop.
Add custom user action through PnP-PowerShell Cmdlets
Connect-SPOnline –Url https://yoursite.sharepoint.com –Credentials (Get-Credential)
$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-SPOCustomAction -Name 'ff1591d2-8613-4a1c-b465-d647a34b2555-GetItemsCount' -Title 'Invoke GetItemsCount Action' -Description 'Adds custom action to custom list ribbon' -Group 'Microsoft.SharePoint.Client.UserCustomAction.group' -Location 'CommandUI.Ribbon' -CommandUIExtension $cUIExtn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment