3

It tried to add a custom button to the DispForm of a element. The Button is visible but not enabled. I tried to add a simple EnableScript but it does not work.

My code:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
  Id="Ribbon.ListForm.Display.AddAButton"
  RegistrationType="List"
  RegistrationId="100"
  Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
         Location="Ribbon.ListForm.Display.Actions.Controls._children">
          <Button
           Id="Ribbon.ListForm.Display.Actions.Controls.AddAButton"
           Alt="Show HelloWorld Alert"

           Command="ShowHelloWorldCommand"
           LabelText="HelloWorld"
           TemplateAlias="o1"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler 
         Command="ShowHelloWorldCommand"
         CommandAction="javascript:alert('Hello World');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
0

You missed EnabledScript in your XML definition. It should look like this:

<CommandUIHandlers>
   <CommandUIHandler 
   Command="ShowHelloWorldCommand"
   CommandAction="javascript:alert('Hello World');"
   EnabledScript="javascript:return true;" />
</CommandUIHandlers>

If that doesn't help try setting the scope of your feature to Web instead of Site.

  • I add this Command: EnabledScript="javascript:function enableButton() { return true; } enableButton();" I forgot to call the function. – user53651 Apr 26 '16 at 9:34
-1

How about following this solution on adding a button on ribbon :

http://www.abelsolutions.com/totm/creating-a-custom-action-in-2-steps-with-sharepoint-designer/

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.