I am trying to add a button to the DisplayForm ribbon that appears in its own group on the ribbon for a specific Content Type in SharePoint 2010.
I have the following definition for the group, tab and button.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://ift.tt/sQmbje">
<CustomAction
Id="{9A955843-20D6-400A-A078-C2DE2CBC7861}"
RegistrationType="ContentType"
RegistrationId="0x010014D754C688D12A4FB4C811B4B4F67A5C"
Location="CommandUI.Ribbon.DisplayForm"
Rights="ViewListItems">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
<Tab Id="{570EB195-4FF9-4ED4-8ABC-52953C444EBA}"
Title="MYTAB"
Description="MY TAB DESCRIPTION"
Sequence="600">
<Scaling Id="{C4CD02B6-120F-4868-88A4-2AFBB1F52D80}">
<MaxSize
Id="{75AC6A65-7FF2-46D6-B5D1-AE61AD65DF94}"
Sequence="10"
GroupId="{7B4A87A5-8047-48AA-81D0-CCD5A5C063A0}"
Size="Large" />
<Scale
Id="{7145A3F1-5087-4A2F-B5E8-55B9A8820974}"
Sequence="20"
GroupId="{7B4A87A5-8047-48AA-81D0-CCD5A5C063A0}"
Size="Large" />
</Scaling>
<Groups Id="{F0F9C1D3-34D7-453B-88D1-A3242E8D0D5A}">
<Group
Id="{7B4A87A5-8047-48AA-81D0-CCD5A5C063A0}"
Sequence="10"
Description="MY GROUP DESCRIPTION"
Title="MYGROUP"
Template="MY.Solution.Ribbon.Templates.ExtendedLarge">
<Controls Id="{1A83D28B-1C26-45E2-89E9-0D38BD6C392A}">
<Button
Id="{740DE751-D405-45BC-B38F-134E1A5C6CF0}"
Alt="SOME ALT TEXT."
LabelText="MY BUTTON LABEL"
Image16by16="/_layouts/images/MY.Solution/SomeIcon_16.png"
Image32by32="/_layouts/images/MY.Solution/SomeIcon_32.gif"
Command="{E1ABCC91-F6E4-43B6-A159-D043BD534599}"
Sequence="99"
TemplateAlias="MY1"
ToolTipTitle="MY BUTTON TITLE"
ToolTipDescription="MY BUTTON DESCRIPTION."/>
</Controls>
</Group>
</Groups>
</Tab>
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.Templates._children">
<GroupTemplate Id="MY.Solution.Ribbon.Templates.ExtendedLarge">
<Layout Title="OneLarge" LayoutTitle="OneLarge">
<Section Alignment="Top" Type="OneRow">
<Row>
<ControlRef DisplayMode="Large" TemplateAlias="MY1" />
</Row>
</Section>
</Layout>
</GroupTemplate>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="{E1ABCC91-F6E4-43B6-A159-D043BD534599}" CommandAction="~site/_layouts/MY.Solution/domsomething.aspx?List={ListId}&ID={ItemId}">
</CommandUIHandler>
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
But I am getting an error after I activate it when I try to view items with a ContentType that this is registered to:
Object reference not set to an instance of an object [NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Web.CommandUI.RibbonRenderer.RenderGroup(DataNode xnGroup, RibbonRenderContext rrc, HtmlTextWriter writer) +1114 Microsoft.Web.CommandUI.RibbonRenderer.RenderTabBody(DataNode xnTab, RibbonRenderContext rrc, HtmlTextWriter writer) +728 Microsoft.Web.CommandUI.RibbonRenderer.RenderRibbon(DataNode xnData, RibbonRenderContext rrc, HtmlTextWriter writer) +5146 Microsoft.Web.CommandUI.Ribbon.AppendRibbon(HtmlTextWriter writer, Boolean headerOnly, UInt32 initialTabScaleIndex, RibbonRenderContext rrc) +76 Microsoft.Web.CommandUI.Ribbon.Render(HtmlTextWriter writer) +1423 Microsoft.SharePoint.WebControls.SPRibbon.Render(HtmlTextWriter writer) +315 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +239 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +252 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +86 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +52 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +239 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +41 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +239 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +239 System.Web.UI.Page.Render(HtmlTextWriter writer) +37 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4239
I seem to be targeting the correct ContentType because the error is appearing when I view the items associated with that ContentType. But I seem to be missing something in the definition of the Custom Action.
What am I doing wrong?

0 commentaires:
Enregistrer un commentaire