Create a Custom Action Specific to a List for SharePoint 2013/SharePoint 2010

You can create a custom action that is based on the list type by editing the elements.xml file that is associated with the custom feature. However, you can also create a custom action that is specific to a list rather than a list type. To do this, create a custom feature for the content type and then make a minor modification in the elements.xml file. The following steps demonstrate how to do this.

Create a custom content type

  1. Create a custom content type by inheriting from any one of the standard Windows SharePoint Services content types.

  2. Ensure that the identifier (ID) of your custom content type has the ID of the base content type (from which it inherits) as its ID prefix.

    The following example XML code shows the elements.xml file for a custom content type that was inherited from the standard Windows SharePoint Services content type, in this case, the List content type.
    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <ContentType ID="0x01AB"
         Name="MyCustomContentType"
         Group="MyCustomContentTypeGroup"
         Description="Customized Content Type"
         Version="0">
       <FieldRefs>
        <FieldRef ID="{8c06beca-0777-48f7-91c7-6da68bc07b69}"
         Name="Created"
         DisplayName="Field1" />
        <FieldRef ID="{1df5e554-ec7e-46a6-901d-d85a3881cb18}"
         Name="Author"
         DisplayName="Field2" />
       </FieldRefs>
      </ContentType>
    </Elements>

    Create your custom action

    • In the Elements.xml file, create your custom action, as illustrated in the example following.
      <?xml version="1.0" encoding="utf-8" ?>
      <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <!-- Document Library Toolbar New Menu Dropdown -->
         <CustomAction Id="UserInterfaceLightUp.DocLibNewToolbar"
          RegistrationType="ContentType"
          RegistrationId="0x01AB"
          Rights="ManagePermissions"
          Location="EditControlBlock"
          Sequence="1000"
          Title="MY DOCLIB NEW MENU TOOLBAR BUTTON">
         <UrlAction Url="/_layouts/LightupHello.aspx?NewMenu"/>
        </CustomAction>
      </Elements>

      Create the list

      1. Create the list where you want to render the custom action.

      2. Change the default content type of the new list to the custom content type that you created above.

      3. Delete the Item content type from the list. At this point, the custom action will be rendered in the Edit Control Block menu of the specified list.