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

Notifications

Announcements

No record found.

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)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

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

  • Frode Magnussen Profile Picture
    60 on at

    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);

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    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

    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

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 137 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 57

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans