web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

D365 Ribbon Workbench: Trying to disable the Close As Won button on Opportunity until a field has data.

(0) ShareShare
ReportReport
Posted on by

Ok, I'm in the new interface of the Ribbon Workbench for D365.  The new look is good.   This is the first time I'm doing a Customized command for a button.

So the goal is to hide the "Close As Won" button until a field on the form on the Opportunity field has data.

First action according to how I understand the instruction is to right click on the "Close As Won" Field and choose "Customize command".

Customize-command.png

After that, I create an Enable Rule.  On Scott's new Video he advised if I heard him correctly that I should use the Enable Rules if data needs to be read from the form.

So, I create an enable rule and then a Value rule.

ValueRule.png

So If I have this right, it's false until my condition of "Is not Null" is true.

What am I missing here?    The button still shows.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: D365 Ribbon Workbench: Trying to disable the Close As Won button on Opportunity until a field has data.

    Before:

    <EnableRule Id="new.opportunity.CloseAsWon.EnableRule">

           <ValueRule Field="new_totalquoteproductsforopportunity" Value="NULL" InvertResult="true" />

         </EnableRule>

    After:

     </DisplayRules>

       <EnableRules>

         <EnableRule Id="new.opportunity.CloseAsWon.EnableRule">

           <ValueRule Field="new_totalquoteproductsforopportunity" Value="0" InvertResult="true" />

         </EnableRule>

       </EnableRules>

    After the creation of the record the rollup field still showed no value.  Thus I though a Null Value.  But on refreshing the record, the field changed to 0.00 for currency.  The rollup is value is the sum of all products and cost in the grid from the Opportunity product entity.

    A bit thank you , Aric for hanging with me on this.   It's finally working.

  • Community Member Profile Picture
    on at
    RE: D365 Ribbon Workbench: Trying to disable the Close As Won button on Opportunity until a field has data.

    I think I just found a flaw in my thinking.   The form field is a rollup currency field.  So by default it's set to 0.00 which is not null.

    So I think I have to express the currency value.

    I did and the enable rule to the command.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,188 Moderator on at
    RE: D365 Ribbon Workbench: Trying to disable the Close As Won button on Opportunity until a field has data.

    I think I see the problem. In looking at your Xml code above, I saw that you don't have the Enable Rule as part of the command, so it never really gets applied.

    Under the command definition, you should have as follows (replace with your enable rules):

        <CommandDefinition Id="Mscrm.Form.opportunity.MarkAsWon">
          <EnableRules>
            <EnableRule Id="Mscrm.CanWritePrimary" />
            <EnableRule Id="Mscrm.OpportunityIsOpen" />
            <EnableRule Id="Mscrm.IsAvailableInMocaOffline" />
            <EnableRule Id="bgx.opportunity.CheckValue.EnableRule" />
          </EnableRules>
    ...
        </CommandDefinition>

    Enable Rule

    Add the Enable Rule to the Command part of the Solution Elements, and this should hopefully work.

  • Community Member Profile Picture
    on at
    RE: D365 Ribbon Workbench: Trying to disable the Close As Won button on Opportunity until a field has data.

     Ok, this is what that section of the Xml looks like now.   

    <EnableRule Id="new.opportunity.CloseAsWon.EnableRule">
            <ValueRule Field="new_totalquoteproductsforopportunity" Value="NULL" InvertResult="true" />
          </EnableRule>

    I published and the button is still showing.   

    /:<

  • Aric Levin - MVP Profile Picture
    30,188 Moderator on at
    RE: D365 Ribbon Workbench: Trying to disable the Close As Won button on Opportunity until a field has data.

    In a blog post by Scott Durow, it actually says to use the InvertResults. Here is an xml sample:

         <EnableRule Id="new.contact.FirstnameNotEmpty.EnableRule">

           <ValueRule Field="firstname" Value="null" InvertResult="true" />

         </EnableRule>

    You can replace the firstname field with your own custom field.

    See the following post:

    https://ribbonworkbench.uservoice.com/knowledgebase/articles/121427-enable-disable-a-ribbon-button-dynamically-based-o

  • Verified answer
    Community Member Profile Picture
    on at
    RE: D365 Ribbon Workbench: Trying to disable the Close As Won button on Opportunity until a field has data.

    Here's the XML.   Cannot figure out what I'm missing.

    <?xml version="1.0" encoding="utf-16"?>

    <RibbonDiffXml xmlns:xsd="www.w3.org/.../XMLSchema&quot; xmlns:xsi="www.w3.org/.../XMLSchema-instance&quot;>

     <CustomActions />

     <Templates>

       <RibbonTemplates Id="Mscrm.Templates" />

     </Templates>

     <CommandDefinitions>

       <CommandDefinition Id="Mscrm.Form.opportunity.MarkAsWon">

         <EnableRules>

           <EnableRule Id="Mscrm.CanWritePrimary" />

           <EnableRule Id="Mscrm.OpportunityIsOpen" />

           <EnableRule Id="Mscrm.IsAvailableInMocaOffline" />

         </EnableRules>

         <DisplayRules>

           <DisplayRule Id="Mscrm.CanWriteOpportunity" />

         </DisplayRules>

         <Actions>

           <JavaScriptFunction FunctionName="Mscrm.OpportunityCommandActions.opportunityClose" Library="$webresource:Opportunity_main_system_library.js">

             <BoolParameter Value="true" />

           </JavaScriptFunction>

         </Actions>

       </CommandDefinition>

     </CommandDefinitions>

     <RuleDefinitions>

       <TabDisplayRules />

       <DisplayRules>

         <DisplayRule Id="Mscrm.CanWriteOpportunity">

           <EntityPrivilegeRule PrivilegeType="Write" PrivilegeDepth="Basic" EntityName="opportunity" />

         </DisplayRule>

       </DisplayRules>

       <EnableRules>

         <EnableRule Id="new.opportunity.CloseAsWon.EnableRule">

           <ValueRule Field="new_totalquoteproductsforopportunity" Value="NULL" Default="false" />

         </EnableRule>

       </EnableRules>

     </RuleDefinitions>

     <LocLabels />

    </RibbonDiffXml>

  • Community Member Profile Picture
    on at
    RE: D365 Ribbon Workbench: Trying to disable the Close As Won button on Opportunity until a field has data.

    I made the change, Published.  Published customizations.   Close as won is still on the form.    FYI: Nice to here from someone in Teaneck.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,188 Moderator on at
    RE: D365 Ribbon Workbench: Trying to disable the Close As Won button on Opportunity until a field has data.

    You got the right approach, but the should not contain the formula just the value.

    Your value field should contain null, and the decision to use eq or ne is based on the default true or false value.

    In your case, change the value in your default drop down to false, and set the value to null.

    That should do the trick.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans