SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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="">
          <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.

share|improve this question
up vote 1 down vote accepted

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:

share|improve this answer
thanks a lot for the quick reply. Hope this helps me. – Mancy Desaee Jul 4 '13 at 7:54
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

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

share|improve this answer
+1 Of course it needs too! Good Answer! – Benny Skogberg Jul 4 '13 at 12:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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