Hi all
I need JS code to disable my button. I know workbench disable functionality. I only need js code line which disable my custom button.
Thank You
*This post is locked for comments
Hi Nithya Gopinath
Thank You. My requirement is not this but as @Ezgi HAGLUND suggest me the solution. So now this is my solution.
Hi Abdul wahab,
Have you referred the link below?
stackoverflow.com/.../crm-2011-how-to-hide-show-the-ribbon-button-with-javascript
Hi Ezgi HAGLUND
No it is not doing anything. What can I do now?
top.document.getElementById("salesorderdetail|NoRelationship|Form|btnRejectDiscount-Medium").disabled = true;
Can you try this? (sorry for misunderstanding)
My code is also working but it is hiding the button. I need to diable it. Please do let mo know. How may I disable it?
Your code hiding my button. I want to disable it. Please tell me How can I disable it.?
Hi Abdul,
you cannot access the DOM directly, you need to use the Xrm.Page object model.
that's why you get the error.
in you library you can wrte a javascript function like
function foo() {
var field = Xrm.Page.getAttribute('logicalfieldname').getValue();
return (field=='Some Value');
}
that's all it takes
Bas
this is my code that works well:
top.document.getElementById("salesorderdetail|NoRelationship|Form|btnRejectDiscount-Medium").style.display = 'none';
and this is the id where I got from F12:
Hi You code giving me this error
function disableButton() {
var field = Xrm.Page.getAttribute('fieldName').getValue();
if (field == XY) { return true; }
if (field != XY) { return false; }
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
HR-09070029-0 2
ED-30091530-0 1