web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

setDisabled javascript function not working

(0) ShareShare
ReportReport
Posted on by

Hello,

I use custom Javascript onload on a form :

var sousType = Xrm.Page.ui.controls.get("asip_soustype");
sousType.setDisabled(true);

But the field is always enabled.

Any Ideas ?

Thanks,

Paul

*This post is locked for comments

I have the same question (0)
  • Mahendar Pal Profile Picture
    45,095 on at
    RE: setDisabled javascript function not working

    Hi,

    Why don't you simply make this field readonly through field properties instead of java script ?? Is behavior is same for all the form type for example create and update ??

  • Community Member Profile Picture
    on at
    RE: setDisabled javascript function not working

    Hi,

    This field mandatory is editable but when form is saved, it must be locked.

    Paul

  • Mahendar Pal Profile Picture
    45,095 on at
    RE: setDisabled javascript function not working

    Try to call following script onload of form this:

    if(Xrm.Page.ui.getFormType()==2) //check for update

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

    Thanks

  • Aileen Gusni Profile Picture
    44,524 on at
    RE: setDisabled javascript function not working

    Hi paul

    You have no other Business Rule or JS that overwrite it?

  • Suggested answer
    shivaram Profile Picture
    3,315 on at
    RE: setDisabled javascript function not working

    Hi Paul Sypniewski,

    Instead of that code you can try this

    var sousType = Xrm.Page.getControl("asip_soustype");

    sousType.setDisabled(true);

    Hope this helps you.

    Thanks,

    Shiva

  • Community Member Profile Picture
    on at
    RE: setDisabled javascript function not working

    Try the below script


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

     

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans