Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Disable custom ribbon button using java script

Posted on by Microsoft Employee

Hi

I have created a custom Ribbon button using ribbon work bench and associated a command with it, in which when users clicks it, a js functions being called. But, in this function, based on a condition, I want to disable the custom button on ribbon. Suppose I run a Custom Action, and until I get a response, I want to disable this ribbon button.

How is this possible ? 

Best Regards 

*This post is locked for comments

  • Suggested answer
    namratha Profile Picture
    namratha 5 on at
    RE: Disable custom ribbon button using java script

    nice post. thanks for sharing.info....

    [url=https://gotechmantra.com/tamilrockers-proxy/]tamilrockers[/url]

  • Mahima Mantri Profile Picture
    Mahima Mantri 20 on at
    RE: Disable custom ribbon button using java script

    Great post. Thanks for sharing. Sevenmentor offers the best Java course in Pune from industry experts to develop conceptual knowledge of coding with placement assistance.

    Java Course in Pune

  • Prutuja Profile Picture
    Prutuja 5 on at
    RE: Disable custom ribbon button using java script

    Based on the TIOBE Index for June 2016 Java is now more well-known than a variety of widely-used programming languages, including C++, Python, C#, PHP and JavaScript. The statistics on usage posted on various websites illustrate the immense popularity and importance of Java in the present day world. Java is an all-purpose programming language. Certain developers prefer to use Java to build desktop GUI applications as well as other developers create numerous web-based applications using Java technologies. In addition, Java is also used extensively for the development of mobile applications and games for Android which is the mobile platform with the biggest user base. There are plenty of reasons that Java is going to be a major factor over an extended period of time.

    Visit: Java Course in Pune

  • PVenkat Profile Picture
    PVenkat 5 on at
    RE: Disable custom ribbon button using java script

    Hi Amit,

    I have a similar requirement as yours. Need to hide a custom button on a custom action to prevent user from clicking multiple times. So hide it when the user clicks and show it after the JS code execution is complete. Were you able to achieve your requirement. If so, please reply back and let me know how you solved the issue. Thanks!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disable custom ribbon button using java script

    Hi Babak,

    I have a very much similar requirement, in which I have to add one Custom button and need to call Custom action on click of that button.

    In order to prevent user to hit the button multiple time, We want to keep it disabled until Action complete its execution in the background and return the response.

    Once response is received I need to enable the button back.

    Please let me know the best way to achieve this requirement.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disable custom ribbon button using java script

    Hi Ezgi HAGLUND

    Thanks for your reply,

    What does "top" means in the code snippet you provide ?

    ٍEdited

    I used console.log( top.document.getElementById("salesorder|NoRelationship|Form|Command1.Command"));

    it returns null.

    As I read the attributes of the ribbon button, the span you mentioned in the picture, does not contains id attribute. 

    So I did some Search and saw I can read attribute using querySelector as mention here

    Thanks a lot

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disable custom ribbon button using java script

    Hi Babak,

    If you want to disable your button based on spesific condition you can use display rule and enable rule on ribbon workbench.

    Please refer this link for it: ribbonworkbench.uservoice.com/.../121427-enable-disable-a-ribbon-button-dynamically-based-o

    If you want to hide your button with JS here is the code

    top.document.getElementById("command").style.display = 'none';

    To be able use it you need to hit F12 first and get your ribbon's command and paste it "command"  part.

    1222.Ekran-Al_3101_nt_3101_s_3101_.PNG

    Hope I got your problem right and my answer is helpful.

    Regards,

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Disable custom ribbon button using java script

    HI

    Please refer below URL

    garethtuckercrm.com/.../dynamically-disable-ribbon-buttons-in-dynamics-crm

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disable custom ribbon button using java script

    Hi Bas van de Sand

    The display/enable rules does not solve my problem, cause I already bind a custom action for that button, and I want to disable the button inside the custom action.

  • Suggested answer
    Bas van de Sande Profile Picture
    Bas van de Sande 4,383 on at
    RE: Disable custom ribbon button using java script

    Hi Babak,

    In the ribbon workbench you can apply display/enable rules to the custom button. In the rule you have to add a "custom rule". In the custom rule you can refer to a javascript library and function.

    I hope this helps you forward

    Bas

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans