Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have document library and i want to add button that will be visible only for my content type:

    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Document (0x0101) -->
  <ContentType ID="0x0101005e4b5d5098e94baba80f8d1ccf9eb507"
               Name="MyCustomDocument"
               Group="MY Content Types"
               Description="MyCustomDocumentcontent type"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>

    </FieldRefs>
  </ContentType>
</Elements>

How can i do this in sharepoint 2010?

I have example of code but its doenot working:

       <?xml version="1.0" encoding="utf-8"?>
        <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
          <CustomAction Id="ExportVersionHistory.DisplayForm" Location="CommandUI.Ribbon"
      RegistrationType="ContentType"
                        RegistrationId="0x0101005e4b5d5098e94baba80f8d1ccf9eb507"
        >
            <CommandUIExtension>
              <CommandUIDefinitions>
                <CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
                  <Button
                    Id="Ribbon.Documents.Manage.OpenInWizard"
                    Sequence="40"
                    Command="Ribbon.Documents.Manage.HelloWorld.cmdSayHelloWorld"
                    Image16by16="/_layouts/1033/images/formatmap16x16.png" Image16by16Top="-144" Image16by16Left="0"
                    Image32by32="/_layouts/1033/images/formatmap32x32.png" Image32by32Top="-128" Image32by32Left="-256"
                    LabelText="Hello World"
                    ToolTipTitle="Click button to prompt 'Hello World'"
                    ToolTipDescription="Once you click this button, you will get a hello world dialog box "
                    TemplateAlias="o1"/>
                </CommandUIDefinition>
              </CommandUIDefinitions>
              <CommandUIHandlers>
                <CommandUIHandler
              Command="ManoInc.Ribbon.Documents.Manage.HelloWorld.cmdSayHelloWorld"
              CommandAction="javascript:alert('Hi Mano');" />
          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>
    </Elements>

Position where I want to locate my button: enter image description here

When i am removing those lines:

RegistrationType="ContentType"
RegistrationId="0x0101005e4b5d5098e94baba80f8d1ccf9eb507"

Button becomes visible for all my content types. What i am doing wrong and why my button doesnot visible for specific content type?

article http://howtosharepoint.blogspot.com/2010/06/ribbon-basics.html

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You need to specify the RegistrationType="ContentType" and RegistrationId="0x0101005e4b5d5098e94baba80f8d1ccf9eb507" attributes of the custom Action. Follwoing is the example:

<CustomAction
    Id="ExportVersionHistory.DisplayForm"
       RegistrationType="ContentType"
       RegistrationId="0x01"
       Location="CommandUI.Ribbon.DisplayForm"
       Rights="ViewListItems">
              <CommandUIExtension>
                     <CommandUIDefinitions>
                           <CommandUIDefinition
                            Location="Ribbon.ListForm.Display.Manage.Controls._children">
                                  <Button
                                   Id="Ribbon.ListForm.Display.Manage.Controls.ExportVersionHistory"
                                   Alt="Export version history of the item to Microsoft Excel."
                                   LabelText="Export Version History"
                                   Image16by16="/_layouts/images/NY.ExportVersionHistory/Excel_Small.png"
                                   Image32by32="/_layouts/images/NY.ExportVersionHistory/Excel_32.gif"
                                   Command="ExportVersionHistory"
                                   Sequence="99"
                                   TemplateAlias="o1"
                                   ToolTipTitle="Export Version History"
                                   ToolTipDescription="Export version history of the item to Microsoft Excel."/>
                           </CommandUIDefinition>
                     </CommandUIDefinitions>

              </CommandUIExtension>
       </CustomAction>
share|improve this answer
    
Hello.Thanks for answer but can i ask you to check updated question. Maybe you know what the problem is. Thanks. –  Evgeny Jan 21 '13 at 16:33
1  
The reason you are not seeing the ribbon button is that you have lower cases in the content type i.e. the RegistrationId. It will work fine if you change them to uppercases in both the content type definition and the RegistrationId. Moreover, you are trying to show the button in ListView. However, the above code will show the ribbon button if the list contains the given content type apart from others. In order to show the ribbon button for specific content types only, you may need to actually create a ribbon button in places like Display form or ECB menu. –  Nadeem Yousuf Jan 22 '13 at 10:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.