1

I want to change the EnabledScript function of a existing Ribbon Button (Upload Document) but keep everything else, like the original CommandAction it executes on click. More specifically I would like to disable the Button in the Top-Level View, because there should only be folders. Inside a folder the Button should be enabled. (I have SP2013 if that matters).

I tried to change the button with a CustomAction but this only removed the whole button (see below). I also tried to modify the button with a Script that disables the button if needed but this did not work as exptected.

<CustomAction
  Id="AddDisable1"
  Location="CommandUI.Ribbon"
  RegistrationId="10002"
  RegistrationType="List"
  Sequence="999">
  <CommandUIExtension>
    <CommandUIDefinitions>
      <CommandUIDefinition Location="Ribbon.Documents.New.AddDocument">
        <Button
          Id="Ribbon.Documents.New.AddDocument"
              Command="AddDisable1cmd"
          />
      </CommandUIDefinition>
    </CommandUIDefinitions>
    <CommandUIHandlers>
      <CommandUIHandler Command="AddDisable1cmd"
        CommandAction="javascript:return (true);"
        EnabledScript="javascript:uploaderEnabled();" />
    </CommandUIHandlers>
  </CommandUIExtension>
</CustomAction>

I would prefer not to copy the button and only change the EnabledScript Section in the Command Handler. How can I change the Enabled function but keep the rest in its default state?

Update: Copying the Button as it is defined in the CMDUI.XML file and using UploadDocument as the command (default) and adding a Handler for UploadDocument did call the original functions and ignored my Actions.

As an alternative: If I cannot replace just the enabled-script, what JS does the original Upload Document Button call? This way I could at least create a new custom copy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.