Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Hide Ribbon button using javascript code in crm 365

Posted on by 335

Hello,

i have requirement,overthere i want to hide ribbon button based on filed's value(like if field value has blank then it will visible otherewise it will be hide).

i know it colud be happen through display rule of ribbon(using Value rule).

but i want to do using javascript code only.

Thanks,

regards.

*This post is locked for comments

  • Verified answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Hide Ribbon button using javascript code in crm 365

    Hi Yash,

    I believe you could do it using enable rule in ribbon workbench.

    Please refer below code for your reference:

    var Value = Xrm.Page.getAttribute("logicalnameoffield").getValue();

    if (Value == null || Value == "")

    return true;

    else {

    return false;

    }

    To add enable rule for your reference:

    ribbonworkbench.uservoice.com/.../121427-enable-disable-a-ribbon-button-dynamically-based-o

  • Suggested answer
    Ammar Zaied Profile Picture
    Ammar Zaied 1,670 on at
    RE: Hide Ribbon button using javascript code in crm 365

    Hi Yash,

    Create a Dialog Short-Cut Ribbon Button

  • Jorge Gomez Profile Picture
    Jorge Gomez 150 on at
    RE: Hide Ribbon button using javascript code in crm 365

    Hello Yash,

    I highly recommend you to do this making use of the Ribbon Workbench, to do it using javascript code only, you will be forced to make use of unsupported code, accessing the DOM, which is not supported and not recommended by Microsoft.

    "JavaScript developers are used to interacting with Document Object Model (DOM) elements in code. You might use the window.getElementById method or the jQuery library. You are free to use these techniques in your HTML web resources, but they are not supported to access elements in Dynamics 365 for Customer Engagement application pages or entity forms. Instead, access to entity form elements are exposed through the Client API object model. The Dynamics 365 for Customer Engagement development team reserves the right to change how pages are composed, including the ID values for elements, so using the Client API object model protects your code from changes in how pages are implemented."

    docs.microsoft.com/.../use-javascript

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans