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 CRM (Archived)

How can I disable Account Deactivate button using Javascript?

(0) ShareShare
ReportReport
Posted on by 230

I am currently using a script to check a users role and then disable certain fields with javascript, like so:

Xrm.Page.getControl("address1_line1").setDisabled(true);

Is there a way to this with the deactivate button?

I've read you can download Ribbon editors, but that doesn't really appeal to me as I already have all the logic in place in my script regarding what roles can access what.  It would be a lot simpler to manage everything in one place.  If it's not possible, what's the recommended way to edit the ribbon?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    jlattimer Profile Picture
    24,562 on at

    The ideal way is to use a ribbon editor - Ribbon Workbench is the best choice. From there you can create an enable rule on the button that calls a JavaScript function from a web resource (so maybe you can re-use what you've already created). The function would return a boolean value to indicate ithe state of the button. The reason for making these changes in the ribbon as opposed to in script defined in the form properties is that the SDK doesn't provide a supported mechanism to reference a control in the ribbon directly. Yes you could probably inspect the source of the page and get the Id of the control and work some JavaScript to disable it but that isn't supported. Unsupported meaning Microsoft could out of the blue one day decide to change the Id of the control and your code would break. Since they haven't documented a means to access the ribbon controls from the form they aren't really obligated to announce such a change. 

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans