Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

Show/Hide Close as Won based on 2 field values

Posted on by 175

On the Opportunity record, I have a requirement that once in the "Close Bid" business process flow stage, when either of the fields "Date Submitted" or "Proposal Submitted", that only then will a user see the 'Close as Won' button in the ribbon, else, it is hidden. 

I currently have this button hidden with Ribbon Workbench, and am using a custom field and a workflow to close the record, but am running into some issues when reopening, etc. 

Does anyone have sample code to show/hide the button based on the above?  This way my issues will be resolved, and the users can have the full OOB Close as Won dialog box functionality.  Let me know, thanks!

 

  • William Bradley Profile Picture
    William Bradley 175 on at
    RE: Show/Hide Close as Won based on 2 field values
    1. In SOLUTION ELEMENTS > ENABLE RULES, click the + to add a new Enable Rule, select ValueRule
    2. In this scenario, we want to Hide the Close as Won, EXCEPT when the field Date Submitted contains data, OR the field Proposal Submitted = Completed. To do this, we Add the field schema names, Values, and InvertResult as shown:
    3. Now we add the Enable Rule as a COMMAND to the Button. Click COMMANDS > Mscrm.Form.opportunity.MarkAsWon (this is the name of the Close as Won button in Ribbon Workbench)
    4. Publish Solution, refresh in D365 and test!
      This was a great solution to showing/Hiding the Close as Won button that works seamlessly in v9.0 and above, without combining with any JScript code, unlike previous versions of D365/CRM.  

    pastedimage1593708035917v2.png

    pastedimage1593708043398v3.png

    pastedimage1593708054455v4.png

  • William Bradley Profile Picture
    William Bradley 175 on at
    RE: Show/Hide Close as Won based on 2 field values

    I believe I figured it out.  I will post steps shortly - thanks guys for your help !!

  • William Bradley Profile Picture
    William Bradley 175 on at
    RE: Show/Hide Close as Won based on 2 field values

    Opened a new solution and started over, here is where I am in Ribbon Workbench, with the same code in D365 for refreshRibbon.  I have added questions below.  I think I just need a step-by-step in order of what to do in Ribbon Workbench.  

    pastedimage1593702682138v1.png

  • a33ik Profile Picture
    a33ik 84,313 Super User on at
    RE: Show/Hide Close as Won based on 2 field values

    Can you please make a screenshot of "Solution Elements" - there is a chance that command was customized already.

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,960 Super User on at
    RE: Show/Hide Close as Won based on 2 field values

    HI,

    You should use  Date Submitted and value as null instead of notnull. Also select invertresult to true.

    for Proposal Submitted you should not select invert result true. it should  be false only.

    Make sure you have mentioned correct fields schema name. If fields are custom field then you are missing prefix in field name.

    If found helpful, Please mark my answer verified.

  • William Bradley Profile Picture
    William Bradley 175 on at
    RE: Show/Hide Close as Won based on 2 field values

    OK, got it to publish with these EnableRules with OR condition, but then was showing the error highlighted below:


    I located the Close as Won button and right-clicked.  How do I add the Command as you mentioned?

    pastedimage1593701564406v1.png

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,313 Super User on at
    RE: Show/Hide Close as Won based on 2 field values

    Not sure regarding the error - you will have to troubleshoot it yourself.

    Regarding the rule - if you haven't added rule to command (in this case it should be rule of you "Win" button) - it will not work so... add this rule to the Command of Win Button.

  • William Bradley Profile Picture
    William Bradley 175 on at
    RE: Show/Hide Close as Won based on 2 field values

    OK, made the updates and get an error on Publish below:
    pastedimage1593700288081v1.png

    As for where I added the enable rule, see screenshot.  I clicked Button, then Solution Elements, then + next to Enable Rules:

    pastedimage1593700378308v2.png

  • a33ik Profile Picture
    a33ik 84,313 Super User on at
    RE: Show/Hide Close as Won based on 2 field values

    So as I assumed rules were not configured the right way.

    For datesubmitted - use null value and 'true' in invert result that can be read as detesubmitted contains some value.

    For presentproposal - you should use either true or false because it's of boolean type. So no 'completed' but 'true' I believe.

    Also can you please show where you've added that enablerule?

  • William Bradley Profile Picture
    William Bradley 175 on at
    RE: Show/Hide Close as Won based on 2 field values

    Also keep in mind that both fields mentioned above are in the Business Process Flow (I have them on the form also, but hidden)

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,513 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,862 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans