Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7158687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:06:26+00:00 2026-05-28T13:06:26+00:00

I would like to conditionally disable a System Ribbon = AddNew in a CRM

  • 0

I would like to conditionally disable a System Ribbon = AddNew in a CRM 2011 form with javascript. That means if the statusCode is X or Y disable the Ribbon, how could I do this?

I tryed to get the ID of the Ribbon in order to change the classname of the Ribbon to disabled, but I got Null because the Ribbons are loaded asychronously!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:06:27+00:00Added an answer on May 28, 2026 at 1:06 pm

    To expand on Anwar’s answer, the key to getting this to work is to intercept and repurpose the functionality of the AddNew 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.

    1) Create a solution with the Application Ribbon included.

    2) Find in the SDK the sample ribbon for the Application Ribbon or build it yourself using the solution included in the SDK.

    \sdk\resources\exportedribbonxml

    \sdk\samplecode\cs\client\ribbon\exportribbonxml\exportedribbonxml

    3) Find in the Application Ribbon template the control you’re interested in, which I assume in this case is the AddNew button in entity subgrids. Repurpose this control in a CustomAction and make the location of the CustomAction the same name as the control you want to repurpose.

    <CustomAction Id="YourOrg.SubGrid.{!EntityLogicalName}.AddNewStandard" 
        Location="Mscrm.SubGrid.{!EntityLogicalName}.AddNewStandard">
      <CommandUIDefinition>
        <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" />
      </CommandUIDefinition>
    </CustomAction>
    

    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 CommandDefinition, add in your own custom rule (in this case, a new EnableRule).

    <CommandDefinition Id="Mscrm.AddNewRecordFromSubGridStandard">
      <EnableRules>
        <EnableRule Id="Mscrm.AppendToPrimary" />
        <EnableRule Id="Mscrm.EntityFormIsEnabled" />
        <EnableRule Id="YourOrg.DisableNewStuff" /> <!--your custom rule-->
      </EnableRules>
      <DisplayRules>
        <DisplayRule Id="Mscrm.ShowForOneToManyGrids" />
        <DisplayRule Id="Mscrm.AppendToPrimary" />
        <DisplayRule Id="Mscrm.CreateSelectedEntityPermission" />
        <DisplayRule Id="Mscrm.AppendSelected" />
        <DisplayRule Id="Mscrm.HideAddNewForChildEntities" />
      </DisplayRules>
      <Actions>
        <JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.addNewFromSubGridStandard" 
              Library="/_static/_common/scripts/RibbonActions.js">
          <CrmParameter Value="SelectedEntityTypeCode" />
          <CrmParameter Value="PrimaryEntityTypeCode" />
          <CrmParameter Value="FirstPrimaryItemId" />
          <CrmParameter Value="PrimaryControl" />
        </JavaScriptFunction>
      </Actions>
    </CommandDefinition>
    

    5) Here is where Anwar’s answer comes in: using both the OrRule and the ValueRule, define your EnableRule to check on the statuscodes of the entity. The linked demonstration relates to a new ribbon button, but the same rules work for repurposed ribbon controls as well.

    Publish your changes when you’re done and your ribbon should be all set. Because I’m not sure how familiar you are with RibbonXml, I’ll also mention that Microsoft has some comprehensive walkthroughs that are pretty helpful (after much time studying them!) in picking it up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to conditionally set expires headers on images so that they will
I would like to have a template that extends another conditionally. Basically, when a
I would like to conditionally compile certain parts of code based on Compiler Type
I would like to apply a background-color style conditionally in the itemTpl of a
i would like to make a textblock tooltip conditionally visible. i have the tooltip
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to build a generic class that I can use to implement
I have an iPad app that I would like to make Universal, however this
I have a situation where I would like to conditionally slice a string from
I would like to know how could I retrieve my jsf component value, when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.