Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

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

  • account payable Profile Picture
    account payable 670 on at
    RE: how to disable and enable text box field (Distributor/Supplier)while select category option set

    Thank you Akanksha Ranjan

    javascript working fine thanks a lot

  • Verified answer
    Akanksha Ranjan Profile Picture
    Akanksha Ranjan 460 on at
    RE: how to disable and enable text box field (Distributor/Supplier)while select category option set

    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.
  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: how to disable and enable text box field (Distributor/Supplier)while select category option set

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans