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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to show/hide Ribbon Button based on view name in Dynamics 365

(0) ShareShare
ReportReport
Posted on by 110

Hi,

I want to show / hide ribbon button based on view name . For eg , when i open contacts in Dynamics 365 , by default "My Active Contacts" view is opened and i have created another custom view "RL Contacts" . So i want to hide Ribbon button in one view i.e "My Active Contacts" and when "RL Contacts" view is opened then ribbon button should be visible.

So how can i do this?

i tried following below url where it has explained adding some enable rules in ribbon workbench . So i have tried it .This approach only disable ribbon button . it does not hide it.

I want that this ribbon button should be hidden too not only disabled.

https://community.dynamics.com/crm/b/mscrmcustomization/posts/hide-ribbon-button-based-on-view-selected

Thanks

I have the same question (0)
  • Suggested answer
    Luis Nogueira Profile Picture
    on at

    Hi,

    To hide the button you need a display rule.

    Please follow ribbonworkbench.uservoice.com/.../76681-hide-a-standard-out-of-the-box-button-based-on-a

  • Dynamics 365 Sumit Thakran Profile Picture
    110 on at

    Hi  Luis Nogueira ,

    Thanks for sharing post . Hiding by adding enable rule is understood by me.

    But condidtion based on which ribbon button will be hidden that is not working for me

    I want to hide ribbon button based on View Name.  Any idea about that ?

    Thanks

  • Mayank Pujara Profile Picture
    830 on at

    try to do this using display rule to see if this resolves your issue...

    pastedimage1579778293575v1.png

  • Dynamics 365 Sumit Thakran Profile Picture
    110 on at

    Hi Mayank,

    i am able to hide using display rule but i am not able to fetch view name in custom javascript

    Can you suggest some command which will fetch view name so that based on view name i will be able to show or hide ribbon button.

    Thanks

  • Suggested answer
    Syed Ibrahim Profile Picture
    6,257 on at

    Please create command(Pass the CRM parameter to JS fucntion) and call the below JS on load to get the view name and then create a Display rule based on the view name.

    GetViewName.png

    function getViewName(selectedCtl) {
        debugger;
        var viewName = selectedCtl.get_viewTitle();
        alert(viewName);
    }

    Call the below method to return Boolean for the display rule.

    function HideButtonBasedOnViewSelected (selectedCtrl) {             
            var query = selectedCtrl.get_viewTitle();
            if (query == 'Your View Name') {
                return false;
            }
            else
                return true;
        }

    Make as Verified, if it resolved your query

  • Dynamics 365 Sumit Thakran Profile Picture
    110 on at

    Hi Syed,

    Thanks for your input.

    I already tried this code snippet shared by you. This only works upto CRM 2015 . It does not work in Dynamics 365.

    I got below javascript error when i used this javascript code snippet.

    Error :- object doesn't support property or method 'get_viewTitle'

    Do you have any idea what code will work in Dynamics 365 ?

  • Suggested answer
    Syed Ibrahim Profile Picture
    6,257 on at

    Hi Sumit,

    I have tested that code and it works in D365 online instance.

    1184.GetViewName.png

  • Dynamics 365 Sumit Thakran Profile Picture
    110 on at

    Hi Syed,

    But i am getting error . Please check my below steps and let me know what i m doing wrong.

    Step1 :- Added  command on Custom ribbon button using Ribon Workbench 2016

    pastedimage1579851232500v1.png

    Step 2 :- Below is web resource created and added js code in text editor as shown below

    pastedimage1579851366953v2.png

    Now after publishing both ribbon workbench changes and web resource . When i am clicking on Ribbon button in Contact view , getting below error

    pastedimage1579851438822v3.png

    I can see your code screenshot , where you have written it , it does not look like in web resource editor.

    Any help will be appreciated.

    Thanks

  • Verified answer
    Syed Ibrahim Profile Picture
    6,257 on at

    Can you please open in classic UI and see. Meanwhile add debugger in the code and see the function triggers or not

  • Dynamics 365 Sumit Thakran Profile Picture
    110 on at

    Hi Syed,

    When i changed my environment setting to Classic UI and refreshed , now its working . JS code is fetching view name.

    Thanks for your help.

    Any idea why its not working in Unified Interface mode ?

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
Pallavi Phade Profile Picture

Pallavi Phade 32

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans