Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 &apos;RibbonCustomAction1&apos; 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.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

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

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

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

share|improve this answer
    
thanks a lot for the quick reply. Hope this helps me. –  Mancy 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 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 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
show 1 more comment

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
add comment

Your Answer

 
discard

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.