Hello,
i have requirement,overthere i want to hide ribbon button based on filed's value(like if field value has blank then it will visible otherewise it will be hide).
i know it colud be happen through display rule of ribbon(using Value rule).
but i want to do using javascript code only.
Thanks,
regards.
*This post is locked for comments
Hi Yash,
I believe you could do it using enable rule in ribbon workbench.
Please refer below code for your reference:
var Value = Xrm.Page.getAttribute("logicalnameoffield").getValue();
if (Value == null || Value == "")
return true;
else {
return false;
}
To add enable rule for your reference:
ribbonworkbench.uservoice.com/.../121427-enable-disable-a-ribbon-button-dynamically-based-o
Hello Yash,
I highly recommend you to do this making use of the Ribbon Workbench, to do it using javascript code only, you will be forced to make use of unsupported code, accessing the DOM, which is not supported and not recommended by Microsoft.
"JavaScript developers are used to interacting with Document Object Model (DOM) elements in code. You might use the window.getElementById method or the jQuery library. You are free to use these techniques in your HTML web resources, but they are not supported to access elements in Dynamics 365 for Customer Engagement application pages or entity forms. Instead, access to entity form elements are exposed through the Client API object model. The Dynamics 365 for Customer Engagement development team reserves the right to change how pages are composed, including the ID values for elements, so using the Client API object model protects your code from changes in how pages are implemented."
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