Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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 Profile Picture
    Aric Levin 30,188 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
    Community Member Microsoft Employee 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 Profile Picture
    Aric Levin 30,188 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
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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 Profile Picture
    Aric Levin 30,188 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans