none
Replacing Version History ribbon button - Version History button seems to be more difficult than other buttons

    Question

  • Hi,

    I'm trying to replace the functionality of the existing Version History ribbon button but it keeps throwing a JavaScript error when I try. The script error happens at:-

    var $addHandler = Sys.UI.DomEvent.addHandler = function Sys$UI$DomEvent$addHandler(element, eventName, handler) {
        /// <summary locid="M:J#Sys.UI.DomEvent.addHandler" />
        /// <param name="element"></param>
        /// <param name="eventName" type="String"></param>
        /// <param name="handler" type="Function"></param>
        var e = Function._validateParams(arguments, [
            {name: "element"},
            {name: "eventName", type: String},
            {name: "handler", type: Function}
        ]);
        if (e) throw e;  <--- throws a null exception error probably because 'element' is null
    


    My elements xml is as follows:-

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction Id="Ribbon.ListForm.Display.Manage.Stuff"
            Location="CommandUI.Ribbon"
            RegistrationId="100"
            RegistrationType="List">
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.VersionHistory">
              <Button Id="Ribbon.ListForm.Display.Manage.MyVersionHistory"
                  Command="EmailLink"
                  Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-48" Image16by16Left="-80"
                  Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-64" Image32by32Left="-448"
                  LabelText="$Resources:core,cui_ButVersionHistory;"
                  ToolTipTitle="$Resources:core,cui_ButVersionHistory;"
                  ToolTipDescription="$Resources:core,cui_STT_ButDocumentVersionHistory;"
                  TemplateAlias="o1"/>
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
             Command="EmailLink"
             CommandAction="javascript:alert('Hello');"/>
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>
    </Elements>
    
    


    Any ideas? If i change the Location attribute of CommandUIDefinition to something else, it seems to work. The alternative workaround is to remove the Version History button and just add a new one although I'd prefer to just replace the Version History button.

     

    Any help would be much appreciated.

     

    Kind Regards

    Chris

     

    Tuesday, December 20, 2011 6:08 AM