I created a custom action in the ribbon by VS. I see the button always. Also when no list items are selected. How can I enable the button only when 1 or more listitems are selected?
This is my current custom action code:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="85691508-c076-4f43-93d4-96b4d5253a09.RibbonCustomAction1"
RegistrationType="ContentType"
RegistrationId="0x0101000ACB09B019144AB4A7A9EDD1CCCC4ED3"
Location="CommandUI.Ribbon"
Sequence="10001"
Rights="AddListItems"
Title="Invoke 'RibbonCustomAction1' action">
<CommandUIExtension>
<!--
Update the UI definitions below with the controls and the command actions
that you want to enable for the custom action.
-->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
<Button Id="Ribbon.Documents.Manage.RibbonCustomAction1Button"
Alt="Archive"
Sequence="100"
Command="Invoke_RibbonCustomAction1ButtonRequest"
LabelText="Archive"
TemplateAlias="o1"
Image32by32="_layouts/15/images/placeholder32x32.png"
Image16by16="_layouts/15/images/placeholder16x16.png" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Invoke_RibbonCustomAction1ButtonRequest"
CommandAction="javascript:alert(SP.ListOperation.Selection.getSelectedItems().length);" />
</CommandUIHandlers>
</CommandUIExtension >
</CustomAction>
</Elements>