Friday, November 19, 2010

Custom Ribbon Actions in SharePoint 2010 - Elements.xml

Custom action to add a Ribbon button in the Display Form of a SharePoint List:

<CustomAction Description="Prints a single List Item" Title="Print List Item" Id="{055c63b4-58d8-4b4a-a366-70f69257b491}" Location="CommandUI.Ribbon.DisplayForm" RegistrationId="100" RegistrationType="List" Sequence="0" Rights="ViewListItems" xmlns="http://schemas.microsoft.com/sharepoint/">
    <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
    <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
          <Button Id="{C75857A4-C0BC-439A-813A-A1DCC885A14A}" Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" Image32by32="~site/_layouts/Icon/PrintIcon.jpg" Image16by16="~site/_layouts/Icon/PrintIcon.jpg" Sequence="0" LabelText="Print List Item" Description="Prints a Single List Item" TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" CommandAction="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

Custom action to add a Ribbon button in the Display Form of a SharePoint Task List:

<CustomAction Description="Prints a single List Item" Title="Print List Item" Id="{055c63b4-58d8-4b4a-a366-70f69257b491}" Location="CommandUI.Ribbon.DisplayForm" RegistrationId="107" RegistrationType="List" Sequence="1000" Rights="ViewListItems" xmlns="http://schemas.microsoft.com/sharepoint/">
    <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
    <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
          <Button Id="{C75857A4-C0BC-439A-813A-A1DCC885A14A}" Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" Image32by32="~site/_layouts/Icon/PrintIcon.jpg" Image16by16="~site/_layouts/Icon/PrintIcon.jpg" Sequence="1000" LabelText="Print List Item" Description="Prints a Single List Item" TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" CommandAction="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

Custom action to add a Ribbon button in the Display Form of a SharePoint Document Library:

<CustomAction Description="Prints a single List Item" Title="Print List Item" Id="{055c63b4-58d8-4b4a-a366-70f69257b491}" Location="CommandUI.Ribbon.DisplayForm" RegistrationId="101" RegistrationType="List" Sequence="1000" Rights="ViewListItems" xmlns="http://schemas.microsoft.com/sharepoint/">
    <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
    <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
          <Button Id="{C75857A4-C0BC-439A-813A-A1DCC885A14A}" Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" Image32by32="~site/_layouts/Icon/PrintIcon.jpg" Image16by16="~site/_layouts/Icon/PrintIcon.jpg" Sequence="1000" LabelText="Print List Item" Description="Prints a Single List Item" TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" CommandAction="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

Custom action to add an item in the Edit Control Block of a SharePoint List:

<CustomAction Id="PrintListItem.ItemToolbar"
  GroupId="PrintListItem"
  RegistrationType="List"
  RegistrationId="100"
  Location="EditControlBlock"
  Sequence="100"
  Title="Print List Item"
  ImageUrl ="/_layouts/Icon/PrintIcon.jpg">
  <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}"/>
</CustomAction>

Custom action to add an item in the Edit Control Block of a SharePoint Task List:

<CustomAction Id="PrintListItem.ItemToolbar" GroupId="PrintListItem" RegistrationType="List" RegistrationId="107" Location="EditControlBlock" Sequence="300" Rights="ViewListItems"
Title="Print List Item" ImageUrl ="/_layouts/Icon/PrintIcon.jpg"><UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}"/></CustomAction>

Custom action to add an item in the Edit Control Block of a SharePoint Document Library:

<CustomAction Id="PrintListItem.ItemToolbar"
  GroupId="PrintListItem"
  RegistrationType="List"
  RegistrationId="101"
  Location="EditControlBlock"
  Sequence="300"
  Rights="ViewListItems"
  Title="Print List Item"
  ImageUrl ="/_layouts/Icon/PrintIcon.jpg">
    <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}"/>
    <!--<UrlAction Url="javascript:window.open('{SiteUrl}/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}','PrintListItem','height=600,width=800,resizable=yes,scrollbars=1');"/>-->
  </CustomAction>

Custom action to add a Ribbon item in the SharePoint 2010 Standard Actions Menu of a SharePoint List:

<CustomAction   GroupId="ActionsMenu" Location="Microsoft.SharePoint.StandardMenu" Sequence="1000" Title="Print List Item" ImageUrl="/_layouts/Icon/PrintIcon.jpg" Description="Print list item" RegistrationType="List">
<UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
</CustomAction>

Will keep updating this post with more Custom Action elements in the future.