Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To expand on Anwar's answer, the key to getting this to work is to intercept and repurpose the functionality of the <code>AddNew</code> ribbon button, but once you do, there won't be any need for hacking the Ribbon DOM. Below are a few steps that you can take to get there.</p> <p>1) <a href="http://gtcrm.wordpress.com/2011/01/19/how-to-view-ribbon-definitions-in-crm-2011-2/" rel="nofollow" title="Adding a Button to the Main CRM Ribbon in 2011">Create a solution with the Application Ribbon included.</a></p> <p>2) Find in the SDK the sample ribbon for the Application Ribbon or build it yourself using the solution included in the SDK. </p> <blockquote> <blockquote> <p>\sdk\resources\exportedribbonxml</p> <p>\sdk\samplecode\cs\client\ribbon\exportribbonxml\exportedribbonxml</p> </blockquote> </blockquote> <p>3) Find in the Application Ribbon template the control you're interested in, which I assume in this case is the <code>AddNew</code> button in entity subgrids. Repurpose this control in a <code>CustomAction</code> and make the location of the <code>CustomAction</code> the same name as the control you want to repurpose.</p> <pre class="lang-xml prettyprint-override"><code>&lt;CustomAction Id="YourOrg.SubGrid.{!EntityLogicalName}.AddNewStandard" Location="Mscrm.SubGrid.{!EntityLogicalName}.AddNewStandard"&gt; &lt;CommandUIDefinition&gt; &lt;Button Id="Mscrm.SubGrid.{!EntityLogicalName}.AddNewStandard" Command="Mscrm.AddNewRecordFromSubGridStandard" Sequence="20" LabelText="$Resources(EntityDisplayName):Ribbon.SubGrid.AddNew" Alt="$Resources(EntityDisplayName):Ribbon.SubGrid.AddNew" Image16by16="/_imgs/ribbon/NewRecord_16.png" Image32by32="/_imgs/ribbon/newrecord32.png" TemplateAlias="o1" ToolTipTitle="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipTitle" ToolTipDescription="$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipDescription" /&gt; &lt;/CommandUIDefinition&gt; &lt;/CustomAction&gt; </code></pre> <p>4) Find in the Application Ribbon template the definition of the command of this button, and using the exact definition as the basis of a new <code>CommandDefinition</code>, add in your own custom rule (in this case, a new <code>EnableRule</code>).</p> <pre class="lang-xml prettyprint-override"><code>&lt;CommandDefinition Id="Mscrm.AddNewRecordFromSubGridStandard"&gt; &lt;EnableRules&gt; &lt;EnableRule Id="Mscrm.AppendToPrimary" /&gt; &lt;EnableRule Id="Mscrm.EntityFormIsEnabled" /&gt; &lt;EnableRule Id="YourOrg.DisableNewStuff" /&gt; &lt;!--your custom rule--&gt; &lt;/EnableRules&gt; &lt;DisplayRules&gt; &lt;DisplayRule Id="Mscrm.ShowForOneToManyGrids" /&gt; &lt;DisplayRule Id="Mscrm.AppendToPrimary" /&gt; &lt;DisplayRule Id="Mscrm.CreateSelectedEntityPermission" /&gt; &lt;DisplayRule Id="Mscrm.AppendSelected" /&gt; &lt;DisplayRule Id="Mscrm.HideAddNewForChildEntities" /&gt; &lt;/DisplayRules&gt; &lt;Actions&gt; &lt;JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.addNewFromSubGridStandard" Library="/_static/_common/scripts/RibbonActions.js"&gt; &lt;CrmParameter Value="SelectedEntityTypeCode" /&gt; &lt;CrmParameter Value="PrimaryEntityTypeCode" /&gt; &lt;CrmParameter Value="FirstPrimaryItemId" /&gt; &lt;CrmParameter Value="PrimaryControl" /&gt; &lt;/JavaScriptFunction&gt; &lt;/Actions&gt; &lt;/CommandDefinition&gt; </code></pre> <p>5) Here is where Anwar's answer comes in: using both the <code>OrRule</code> and the <code>ValueRule</code>, define your <code>EnableRule</code> to check on the <code>statuscode</code>s of the entity. The linked demonstration relates to a new ribbon button, but the same rules work for repurposed ribbon controls as well.</p> <p>Publish your changes when you're done and your ribbon should be all set. Because I'm not sure how familiar you are with <code>RibbonXml</code>, I'll also mention that <a href="http://msdn.microsoft.com/en-us/library/gg334532.aspx" rel="nofollow" title="Ribbon Walkthroughs">Microsoft has some comprehensive walkthroughs</a> that are pretty helpful (after much time studying them!) in picking it up.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload