0

Can I define a SharePoint ribbon or Menu custom action on a generic list without a content type?

I've tried the following with no luck. It doesn't show up in the ribbon.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="PushToNavAction"
    RegistrationType="List"
    GroupId="ActionsMenu"
    Location="Microsoft.SharePoint.StandardMenu"
    Sequence="1000"
    ControlAssembly="Accreda.TicketingSystem.Receivers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0db9e3602d4c2d7d"
    ControlClass="Accreda.TicketingSystem.Receivers.CustomActions.PushToNav"
    Description="Push this SharePoint job to Navision."
    RegistrationId="10002"    
    RequireSiteAdministrator="false"
    Title="PushToNavAction"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
      <!-- Define the (UI) button to be used for this custom action -->
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
          <Button Id="ContentTypeTest.Button"
          Image32by32="~site/_layouts/Accreda.TicketingSystem.Core/Images/UploadToNav_16x16.gif"
          Image16by16="~site/_layouts/Accreda.TicketingSystem.Core/Images/UploadToNav_32x32.gif"
          Sequence="95"
          LabelText="Push to Navision"
          Description="Push this SharePoint job to Navision."
          TemplateAlias="o2"
          Command="ContentTypeCommand"
          CommandType="General"
          />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <!-- Define the action expected on the button click -->
        <CommandUIHandler Command="{4E2F5DC0-FE2C-4466-BB2D-3ED0D1917763}" CommandAction="" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
1

There are two ways how to do it:

  1. Add a custom action and set RegistrationType="List" and RegistrationId="ListTemplateID". E.g.:

<CustomAction Id="DMS.ContentTypes.RegistryOwnerCustomAction" RegistrationType="List" RegistrationId="101" Location="Microsoft.SharePoint.ListEdit" GroupId="GeneralSettings" Sequence="15001" Rights="ManageLists" Title="$Resources:DMS.ContentTypes,RegistryOwnerCustomAction_Title;" > <UrlAction Url="javascript:window.location= '{SiteUrl}/_layouts/DMS/SetRegistryOwner.aspx?List={ListId}&amp;Source='+ escape(window.location)"/> </CustomAction>

  1. Add a custom control to AdditionalPageHead and then override it's OnLoad method. Trim ribbon, add new buttons or menu items from there. E.g.:

<Control ControlAssembly="$SharePoint.Project.AssemblyFullName$" ControlClass="BTMU.CustomActions.PageCustomActions" Sequence="1000" Id="AdditionalPageHead"> </Control>

protected override void OnLoad(EventArgs e) { this.EnsureChildControls(); base.OnLoad(e); this.Visible = false; if (Microsoft.SharePoint.SPContext.Current.FormContext.FormMode == SPControlMode.Edit) { SPRibbon ribbon = SPRibbon.GetCurrent(this.Page); this.RegisterJavaScript(ribbon); ShowCustomActions(ribbon); } }

Continue with article series from here on how to add button to the ribbon programmatically. Advantage of the latter is that you can do various checks more easily (e.g. list URLs, various conditions for enable/disable commands etc.):

2013 is very similar to 2010 except some of the Ribbon Locations are different which you can find here.

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.