Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Show button with javascript

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

  • Frode Magnussen Profile Picture
    Frode Magnussen 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
    Bipin D365 28,964 Super User 2024 Season 1 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
    Frode Magnussen 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
    a33ik 84,323 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

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans