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.
Thanks
function visibilityOfButton(selectedCtrl) {
var viewname = selectedCtrl.getViewSelector().getCurrentView().name;
alert("view name" + viewname);
if (viewname === "My Active Accounts")
visible= true;
else
visible = false;
return visible;
};
Add this to enable rule of the button change the name of the function in the below image to your function name or the above mentioned function name.
Hello,
Please refer to this screenshots.
Use Xrm._page.getUrl() to get the Url and split to get the ID.
OK. Thanks for quick help
We are facing some random controls issues on UCI as well. Keep you posted if we found solution
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 ?
Can you please open in classic UI and see. Meanwhile add debugger in the code and see the function triggers or not
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
Step 2 :- Below is web resource created and added js code in text editor as shown below
Now after publishing both ribbon workbench changes and web resource . When i am clicking on Ribbon button in Contact view , getting below error
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
Hi Sumit,
I have tested that code and it works in D365 online instance.
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 ?
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.
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156