Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Sales forum / How To disable CloseAs...
Sales forum
Answered

How To disable CloseAsWon button with XrmToolBox

Posted on by 448

Hi all

I'm trying to disable button "CloseAsWon" in opportunity, with XrmToolBox.

The button must be disabled until the value of field [opportunity][stepname] not equal to value "4-Chiudi"

I follow this example "ribbonworkbench.uservoice.com/.../121427-enable-disable-a-ribbon-button-dynamically-based-o" but I'm not able to find the way.

This is my screenshot

pastedimage1672915699931v1.png

where I'm mistaken?

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 5,816 Moderator on at
    RE: How To disable CloseAsWon button with XrmToolBox

    No problem buddy great to see it worked : )

  • DiePic Profile Picture
    DiePic 448 on at
    RE: How To disable CloseAsWon button with XrmToolBox

    Hi Amit Katariya007  in this way is perfect and works without coding. 

    Trying to "enable rules" was the wrong way.

    Thanks for your patience and kindness.

    _______________________________________

    This step is also important for success of process:

    Once published, you'll notice that the button will only be enabled if the rules match the criteria when the form is loaded.To make the ribbon dynamically change when a field value changes, you'll need to create a JavaScript Webresource with the following JavaScript function:

    function refreshRibbonOnChange()
    {
        Xrm.Page.ui.refreshRibbon();
    }]
    

    find in: (ribbonworkbench.uservoice.com/.../121427-enable-disable-a-ribbon-button-dynamically-based-o)

  • Verified answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 5,816 Moderator on at
    RE: How To disable CloseAsWon button with XrmToolBox

    So as you can see in the below image I have a Button 2 and close as won button which will be only shown when opportunity status will be "on hold" i.e. value=2

    pastedimage1672995801849v2.png

    when we will see status other than "on hold" then both button will be hidden.

    pastedimage1672995844528v3.png

    Below is my display rules which is applied on both button's command.

    pastedimage1672995919711v4.png

    pastedimage1672995961044v5.png

    Make sure there should not be any space after the given "field"(in my case it is statuscode) in value rule.

    Thank You,

    Amit Katariya

  • DiePic Profile Picture
    DiePic 448 on at
    RE: How To disable CloseAsWon button with XrmToolBox

    Hi Leco Lv thanks for reply

    I would do this without code, but I think that button MarkAsWon has sometingh particular.... if you know how to, please send me a detailed exposition.

    For 2nd point, I noticed and correct.

    Thanks in anyway 

  • DiePic Profile Picture
    DiePic 448 on at
    RE: How To disable CloseAsWon button with XrmToolBox

    Hi Bipin Kumar  thanks for reply.

    I try other ways for this reason you find "parameter name from executionContext to primaryControl" in the screenshot.... I've correct it and try another time for sure.

    Maybe the problem is STEMPNAME, but I'm in opportunity and this is one of fields of the table

    pastedimage1672994374670v1.png

    The way that getting below error, it's your, but give me no expected results


     These below the last test
    pastedimage1672995539038v4.png

    pastedimage1672995467801v2.png

    pastedimage1672995494981v3.png

    I also try to put an alert to see what data is fetched, but the alert doesn't appear

    pastedimage1672995911865v1.png

  • DiePic Profile Picture
    DiePic 448 on at
    RE: How To disable CloseAsWon button with XrmToolBox

    Hi Amit Katariya007 

    In last post of mine, you can view the correction .... thanks in anyway to have remarked it.

  • Leco Lv Profile Picture
    Leco Lv on at
    RE: How To disable CloseAsWon button with XrmToolBox

    Hi Partner,

    1. You can try to use the value rule without js, then change the invert result to true, and the default value can be left blank.

    2022.pastedimage1672985749992v1.png

    2.If using js, I noticed some issues with your code.

    There can be no spaces in get value, the letter v should be capitalized, and the line below getValue() is unnecessary.

    8117.pastedimage1672985900703v2.png

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: How To disable CloseAsWon button with XrmToolBox

    Hi,

    Now you changed parameter name from executionContext to primaryControl ....

    Auto correct changed getValue to get value....

    Use code where you are getting below error

    Can not read properties of null (reading getValue)

    You are getting this error because stepname is not the present on the form..

  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 5,816 Moderator on at
    RE: How To disable CloseAsWon button with XrmToolBox

    Don't use space between getValue function. U have used as get Value, that is incorrect

  • DiePic Profile Picture
    DiePic 448 on at
    RE: How To disable CloseAsWon button with XrmToolBox

    Hi Bipin Kumar  and thanks for your help.

    In your way dont give more errors, but it's not retriving data and form remain unchanged.

    this is the summary after a lot of attempts:

    - XrmToolBox

    pastedimage1672934998404v1.png

    - script

    pastedimage1672935038733v2.png

    thanks in advance for any help

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,339 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans