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 to disable and enable text box field (Distributor/Supplier)while select category option set

(0) ShareShare
ReportReport
Posted on by 670

Dear all

how to disable and enable text box field (Distributor/Supplier)while select category option set

i want to enable textbox field (Distributor/Supplier) while select DISTRIBUTOR from category option set ,please share me javascript code for this

1sp1.JPGsp2.JPGsp3.JPG

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi  Sabih,

    Is there  any specific reason you  want to implement using JavaScript?

    I would suggest create business rules with action lock and unlock ,You don't have to write any code.

    docs.microsoft.com/.../create-business-rules-recommendations-apply-logic-form

  • Verified answer
    Akanksha Ranjan Profile Picture
    460 on at

    Hi Sabih, 

    I will also suggest to choose Business Rule to get this requirement done. But if you still want to go ahead with javascript you can write below mentioned code.

    function enabledDisableField() {
        if (Xrm.Page.getAttribute("Category_Field").getValue() == 2) {
            Xrm.Page.getControl("Distributor/Supplier").setDisabled(false);
           
        } else {
    Xrm.Page.getControl("Distributor/Supplier").setDisabled(true);
        }
    }

    Replace the field name with schema of the field and run the code on form onLoad and onChange.
    Make field Distributor/Supplier disabled by default.

    Please mark answer as Verified, if found helpful.
  • account payable Profile Picture
    670 on at

    Thank you Akanksha Ranjan

    javascript working fine thanks a lot

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