0

I have a custom action for my custom list in SharePoint 2010. I want to display a button under the Actions Group of Items Tab below is my element file. Somehow the button is not appearing on the ribbon. Have tried multiple combination of location for Tab and Group but nothing helped

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="ShowHelloWorldButton" RegistrationType="List" RegistrationId="100" Location="CommandUI.Ribbon.ListItem">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
         Location="Ribbon.ListItem.Actions.Controls._children">
          <Button Id="Ribbon.ListItem.Actions.Controls.ShowHelloWorldButton" Alt="Show HelloWorld Alert" Sequence="9" Image32by32="/_layouts/images/hello.jpg"
           Command="ShowHelloWorldCommand" LabelText="Hello World" CommandType="General"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="ShowHelloWorldCommand" CommandAction="javascript:alert('Hello World');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>   
  • How do you deploy it? Can you share the feature XML code? Are you sure the WSP/feature are correctly deployed/activated? – Evariste Dec 30 '16 at 14:33
  • Hi Evariste, thanks for your reply and a very Happy new Year to you, I checked and the feature was getting correctly deployed. I have figured out the Issue, The list on which i was trying to attach this custom action was having a custom content type bind to it. So instead of registering it to list ID I passed the content type ID and it worked. – SiD Jan 2 '17 at 7:06
1

Silly mistake by me the list have a custom content type attached to it so instead of passing List as registration type and List Id as registration ID i need to pass Registration type as "ContentType" and content type ID as registration ID. Below is the example:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="ShowHelloWorldButton" RegistrationType="ContentType" RegistrationId="0x0100" Location="CommandUI.Ribbon.ListItem">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
         Location="Ribbon.ListItem.Actions.Controls._children">
          <Button Id="Ribbon.ListItem.Actions.Controls.ShowHelloWorldButton" Alt="Show HelloWorld Alert" Sequence="9" Image32by32="/_layouts/images/hello.jpg"
           Command="ShowHelloWorldCommand" LabelText="Hello World" CommandType="General"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="ShowHelloWorldCommand" CommandAction="javascript:alert('Hello World');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
0

I have a doubt about this line:

 <CustomAction Id="ShowHelloWorldButton" RegistrationType="List" RegistrationId="100" Location="CommandUI.Ribbon.ListItem">

Is it "CommandUI.Ribbon.ListItem", or only "CommandUI.Ribbon"? I guess the later is the correct, so I'd try:

 <CustomAction Id="ShowHelloWorldButton" RegistrationType="List" RegistrationId="100" Location="CommandUI.Ribbon">

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.