I want to add new button to the ribbon in Pages library. To do so, I have following code:

<CustomAction Id="Ribbon.PublishTab.Publishing.Actions.UploadDocumentButton" Location="CommandUI.Ribbon">
        <CommandUIDefinition Location="Ribbon.EditingTools.CPInsert.Links.Controls._children" >
          <Button Id="Ribbon.PublishTab.Publishing.UploadDocumentButton1" Command="Test1"
                  LabelText="Upload File" TemplateAlias="o1" Sequence="100" />
        <CommandUIHandler Command="Test1" CommandAction="javascript:function Action()
                          Action();"  EnabledScript="javascript:function JustReturnTrue(){  return true;}JustReturnTrue();" />

The ribbon button appears on proper place. But it is always disabled. After try things, I figured out that when I remove command attribute from <Button> tag it is getting enabled but when I place the same attribute and deploy, it is getting disabled.

What am I missing?

  • I think this because of missing semicolon in after return true statement in JustReturnTrue() method. Jan 27 '15 at 11:46
  • Hello Sir, I added the semicolon(;) after return true (as per my updated question) but getting the same issue. @NadeemYousuf
    – users1100
    Jan 27 '15 at 12:26
  • please try to use developer tools (using f12 regardless of your browser) and check for any javascript errors. Code seems legit. Jan 27 '15 at 13:36
  • Did you ever find a solution to this? I am having a similar problem where the button is always disabled. However, I want it always enabled, so I am not using EnabledScript at all. Mar 4 '16 at 20:38

If your button is enabled in all conditions, try to remove the EnabledScript property.

  • Removed the attribute for enabling the option but not working yet.
    – users1100
    Jan 27 '15 at 12:54
  • 1
    Try this : <CommandUIHandler Command="Test1" CommandAction="javascript:alert('Hello, world');"/>
    – KhalilG
    Jan 27 '15 at 14:42

I had a similar Problem and discovered that removing the space before the commandUIHandler closing tag helped.

So instead of

return true;}JustReturnTrue();" />

do this:

return true;}JustReturnTrue();"/>

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.