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"
            Title="Invoke &apos;RibbonCustomAction1&apos; action">
  Update the UI definitions below with the controls and the command actions
  that you want to enable for the custom action.
    <CommandUIDefinition Location="Ribbon.Library.Actions.Controls._children">
      <Button Id="Ribbon.Library.Actions.RibbonCustomAction1Button"
              Alt="Approve Multiple Forms"
              LabelText="Approve Multiple Forms"
              Image16by16="_layouts/15/images/placeholder16x16.png" />
       function enableMultiApproval()
          context = SP.ClientContext.get_current();
         var web = context.get_web();
         alert('web : ' + 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);
     CommandAction="javascript:alert('test');" />
</CommandUIExtension >

Please guide.


As pointed by @Robert, Enabled script should return boolean value. Your Enabled script should look like this:

   function enableBulkApproveButton() {
   var context = SP.ClientContext.get_current();
   return SP.ListOperation.Selection.getSelectedItems(context).length >= 1;

I guess you are trying to approve multiple documents in a document library. You can have a look at this code: http://sharepointnadeem.blogspot.in/2011/08/approve-multiple-items-in-document.html

  • You are right to some that is I need to approve multiple items but they are infopath forms not documents. If you have any idea regarding it then do help me. – Mancy Desaee Jul 4 '13 at 8:25
  • That should not make any difference. Whether you are approving forms/documents. Both of them will be treated as list items. – Nadeem Yousuf Jul 4 '13 at 9:36
  • This works great. Thanks a ton for this. Can you suggest me an approach for updating the radio button in the infopath form when the form is approved. – Mancy Desaee Jul 4 '13 at 9:55
  • Glad that I could help. I am afraid I can't help ypu with the second part as I don't have the SP 2010 VM available. – Nadeem Yousuf Jul 4 '13 at 10:24
  • No worries! Please suggest me an approach for this. – Mancy Desaee Jul 4 '13 at 11:27

Must not your EnabledScript function return a boolean value; True if the button should be enabled and vice versa.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.