web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Hide Ribbon button using javascript code in crm 365

(0) ShareShare
ReportReport
Posted on by 351

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

I have the same question (0)
  • Verified answer
    Pawar Pravin  Profile Picture
    5,237 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
    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
    152 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans