I have successfully added a new button in the ribbon. But when I check , it is disabled and I cannot even click it. The following is the code that I have used:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="127690cb-1104-4b69-a3df-8b8c9eba36f9.RibbonCustomAction1"
RegistrationType="List"
RegistrationId="115"
Location="CommandUI.Ribbon"
Sequence="10001"
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.Library.Actions.Controls._children">
<Button Id="Ribbon.Library.Actions.RibbonCustomAction1Button"
Alt="Approve Multiple Forms"
Sequence="100"
Command="ApproveMultipleItems"
LabelText="Approve Multiple Forms"
TemplateAlias="o1"
Image32by32="_layouts/15/images/placeholder32x32.png"
Image16by16="_layouts/15/images/placeholder16x16.png" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
EnabledScript="javascript:
function enableMultiApproval()
{
context = SP.ClientContext.get_current();
var web = context.get_web();
alert('web : ' + web);
context.load(web);
var currentlibid = SP.ListOperation.Selection.getSelectedList();
alert('libraryid : '+ currentlibid);
var currentLib = web.get_lists().getById(currentlibid);
alert('currentLib :' + currentLib);
var selectedItems = SP.ListOperation.Selection.getSelectedItems(context);
alert('selectedItems: ' + selectedItems);
}
enableMultiApproval();"
Command="ApproveMultipleItems"
CommandAction="javascript:alert('test');" />
</CommandUIHandlers>
</CommandUIExtension >
Please guide.