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 :
Customer experience | Sales, Customer Insights,...
Answered

Show button with javascript

(0) ShareShare
ReportReport
Posted on by 60

Hi,

I have hidden a button in the ribbon using a DisplayRule, but I can't seem to find any way to show this button using javascript? I can't get a reference to the control using formContext.

I want to hide the button by default. In the OnLoad event I want to make a request to a third party to decide if the button should be visible. 

Is this possible to do?

/Frode

I have the same question (0)
  • Frode Magnussen Profile Picture
    60 on at
    RE: Show button with javascript

    Hi,

    Thanks for the links. I have not tried the approach in the second link. Will try that and let you know how it works.

    /Frode

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Show button with javascript

    Hi,

    I remember in CRM 2013 and 2015 version when we add custom rule under Enable rule button used to disabled or enabled. And to hide/show button we used to use display rule. But this has changed now, Enable rule with customRule will actually show/hide buttons based on return value from Javascript.

    See below article to confirm my theory.

    xrmdynamicscrm.wordpress.com/.../

    xrmdynamicscrm.wordpress.com/.../

    To get the formcontext from Ribbon javascript, you should pass primary control CRM parameter to function. See this in above articles.

    If found helpful, Please mark my answer verified.

  • Frode Magnussen Profile Picture
    60 on at
    RE: Show button with javascript

    Hi,

    Yes thank you. That is our current solution. With an Enable Rule you can create a CustomRule and reference a webresource file and a function to set the rule. This works great, but I have a customer that want to hide/show the button instead. Unfortunately there is no CustomRule type of functionality for the Display Rules. I am looking for a script based solution to solve this if possible.

    /Frodejavascript:void(0);

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Show button with javascript

    Hello,

    You can use Enable Rule that returns the promise - docs.microsoft.com/.../define-ribbon-enable-rules

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
DAnny3211 Profile Picture

DAnny3211 134

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 132

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 70 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans