Skip to content

Instantly share code, notes, and snippets.

@rjesh-git
Created October 27, 2015 17:10
Show Gist options
  • Save rjesh-git/48584f534db1659cfde9 to your computer and use it in GitHub Desktop.
Save rjesh-git/48584f534db1659cfde9 to your computer and use it in GitHub Desktop.
$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>"
$newUCA = $caColl.Add()
$newUCA.set_registrationId("100");
$newUCA.set_registrationType("List");
$newUCA.set_location('CommandUI.Ribbon');
$newUCA.set_title('Invoke GetItemsCount Action');
$newUCA.set_commandUIExtension($cUIExtn)
$newUCA.update()
$ctx.ExecuteQuery()
Write-Host 'Custom action added.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment