3

I want to display a custom action button on the list view only (not on the DisplayForm).

In the example below the Location attribute for the CommandUIDefinition is set to

Ribbon.ListForm.Display.Manage.Controls._children

<CommandUIDefinitions>
    <CommandUIDefinition **Location="Ribbon.ListItem.Display.Manage.Controls._children"**>
      <Button Id="{E22A6CA6-06F0-40E2-B995-34294CAC7422}"
      Command="{2461C3B4-303B-4A19-9610-DD87ECFF7095}"
      Image32by32="~site/_layouts/Images/MYSOLUTION/myimage32.png"
      Image16by16="~site/_layouts/Images/MYSOLUTION/myimage16.png"
      Sequence="0"
      LabelText="Create Child Item"
      Description="Create Child Item"
      TemplateAlias="o1"/>
    </CommandUIDefinition>
  </CommandUIDefinitions>

But there is also a Location attribute in the CustomAction definition too.

In my example this Location attribute in the CustomAction attribute is set to:

CommandUI.Ribbon.DisplayForm

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="{F448A055-B646-455E-94AB-64C7A9122789}"
RegistrationType="ContentType"
RegistrationId="0x0100B7080A7BAA48E54694292941D7204275"
**Location="CommandUI.Ribbon.ListView"**
Rights="ViewListItems">
<CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Define the (UI) button to be used for this custom action -->
  <CommandUIDefinitions>

Both Location attributes seem to target different locations even though they are specifying the same custom action location.

[EDIT]

In my example I am adding screenshot as suggested to show the locations:

This Shows The Custom Action button and tab on the List View

and then the same action also appears on the DisplayForm as in the screenshot below:

This shows the Custom Action button also on the DisplayForm tab even though I do not want it to appear there. Is there a full list of these locations for the CommandUIDefinition Location attribute?

3

Yes there is. Take a look at the contents of this - C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\GLOBAL\XML\CMDUI.xml. You'll find all the locations.

3

It is a two step process. The Location="CommandUI.Ribbon.DisplayForm" of CustomAction specifies that a button will be added to Display form. And Location="Ribbon.ListForm.Display.Manage.Controls._children"> of CommandUIDefinition specifies that it will be added to the Manage tab of the Display form. Full Example:

<CustomAction
    Id="ExportVersionHistory.DisplayForm"
    RegistrationType="ContentType"
    RegistrationId="0x01"
    Location="CommandUI.Ribbon.DisplayForm"
    Rights="ViewVersions">
        <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>
            <CommandUIHandlers>
                <CommandUIHandler
                 Command="ExportVersionHistory"
                 CommandAction="~site/_layouts/NY.ExportVersionHistory/ExportVersionHistory.aspx?List={ListId}&amp;ID={ItemId}"
                 EnabledScript="javascript:ExportVersionHistoryDisplayFormEnable();"/>
            </CommandUIHandlers>
        </CommandUIExtension>
    </CustomAction>

See this for more information about Custom Action Locations: https://msdn.microsoft.com/en-us/library/office/bb802730.aspx?f=255&MSPPError=-2147217396

UPDATE

Based on your update, it appears you want to add a new tab only in ListView. Set CustomAction Location to CommandUI.Ribbon.ListView and in CommandUIDefinition set Location="Ribbon.Tabs._children" See these articles on how to create a tab in ribbon: http://www.sharepointnutsandbolts.com/2010/01/customizing-ribbon-part-1-creating-tabs.html http://blogs.msdn.com/b/sharepointdeveloperdocs/archive/2009/12/07/sharepointfoundationhowtoaddtabtoribbon.aspx

  • So how can I add it only to the list view and not to both the display form & list view? – motionpotion Feb 25 '15 at 13:59
  • For List view the Custom Action will have Location="CommandUI.Ribbon.ListView" and for CommandUIDefinition it may be similar to this Location="Ribbon.ListItem.Manage.Controls._children"> – Nadeem Yousuf Feb 25 '15 at 14:02
  • But I don't want the button to appear on the list item. I need a way for it only to appear on the list view. – motionpotion Feb 25 '15 at 14:04
  • I am not able to get you. Can you add a screenshot in the question showing where you want the button in the ribbon? – Nadeem Yousuf Feb 25 '15 at 14:06
  • I have updated my question with the screenshots. I tried Location="Ribbon.ListItem.Manage.Controls._children" but it does not work. Currently the custom action tab appears in both the List View and DisplayForm when it should only appear in the List View. – motionpotion Feb 25 '15 at 15:24

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.