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 am adding a custom button to SP Ribbon with exactly same functionality as OOTB "Save and Close" button. I am trying to add it though custom action but other solutions are welcome as well. My problem with custom action is that Command Action is not firing

  <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="Ribbon.CustomAction2"
                Location="CommandUI.Ribbon"
                Title="Custom Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.WikiPageTab.EditAndCheckout.Controls._children">
          <Button Id="Ribbon.CustomAction.Button2"
                  Sequence="30"
                  Alt="$Resources:core,save;"
Command="ECMAScriptComand"
CommandValueId="PageStateGroupSaveAndStop"
Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-176" Image16by16Left="-96"
Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-320" Image32by32Left="0"
                  LabelText="Workflows"
                  TemplateAlias="o1"
                  />
        </CommandUIDefinition>
      </CommandUIDefinitions>            
      <CommandUIHandlers>
        <CommandUIHandler Command="ECMAScriptComand"                          
                          CommandAction="javascript:HelloWorld()">
        </CommandUIHandler>
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
  <CustomAction Id="Ribbon.Library.Actions.NewButton.Script"
    Location="ScriptLink"
    ScriptBlock="
    function HelloWorld()
    {
      alert('Hello, world!');
       var result=CoreInvoke('PageActionClick', this);
       alert(result);
    }" />
  </Elements>
share|improve this question

1 Answer 1

can you please refer to these for guidance!

http://msdn.microsoft.com/en-us/library/ff458385.aspx

and

http://msdn.microsoft.com/en-us/library/ms460194.aspx

I dont understand why your script block that your calling is in a different customAction? as I can see from msdn the customAction surrounds the creation of the button and the javascript CommandAction.

I could be wrong tho :) ...

<CommandUIHandlers> 
  <CommandUIHandler 
    Command="ECMAScriptComand"    
    CommandAction="javascript:
     function HelloWorld() 
      { 
        alert('Hello, world!'); 
        var result=CoreInvoke('PageActionClick', this); 
        alert(result); 
      }"/>
</CommandUIHandlers> 

This is a nice link shows you step by step guide adding a button :) http://www.a2zmenu.com/Tutorials/SharePoint/How-to-add-ribbon-button-in-SharePoint-list-and-library.aspx

share|improve this answer

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.