Forums

Forums / Developing Portals / How do you set a field to read only dynamically?

How do you set a field to read only dynamically?

Thread is closed for posting
3 posts, 1 answered
  1. geoff.white
    geoff.white avatar
    31 posts
    Registered:
    27 Jan 2015
    13 Feb 2017
    Link to this post
    I want to set a picklist to be readonly based on its value. How do I achieve this? There isn't any documentation in the API on how to set this using javascript.

    I don't want that field to submit any value to CRM.

    Disabling the field still submits the original value.
  2. geoff.white
    geoff.white avatar
    31 posts
    Registered:
    27 Jan 2015
    26 Feb 2017 in reply to geoff.white
    Link to this post
    Bump. Any answers to this?
  3. Clinton Bale
    Clinton Bale avatar
    126 posts
    Registered:
    21 Feb 2014
    Answered
    28 Mar 2017 in reply to geoff.white
    Link to this post
    Hello Geoff,

    Sorry for the late response! Below is a code snippet you can use to disable/make-readonly a Picklist widget using both TPC 3.3 or TPC 4.0 apis:

    $(function(){
        //TPC 4.0+
        var pl = tpc.find("gendercode");
        pl.disable();
    
        //TPC 3.3
        var pl = findControl("gendercode");
        pl.disable();
    });
    

    Let me know if this answers your question.

    Regards,
    Clinton
3 posts, 1 answered