Forums

Forums / Developing Portals / How To set Pick List to choose default values

How To set Pick List to choose default values

Thread is closed for posting
5 posts, 1 answered
  1. Krishna Hari
    Krishna Hari avatar
    65 posts
    Registered:
    05 Dec 2019
    Answered
    22 Jan 2020
    Link to this post
    I have a grid add form which gets an attribute Ceutypeid as a querey string.  I am able to see the option in the pick list drop down after filtering the entity with the querey string but i would like to select it by default
    Ho do I go about it
  2. Alex
    Alex avatar
    19 posts
    Registered:
    27 Sep 2018
    22 Jan 2020 in reply to Krishna Hari
    Link to this post
    Hello Krishna,
    Take a look at our Portal Hero Blog, we have several articles that talk about custom JavaScript code and how to select values on our widgets. If you need assistance finding them please let me know and I will post them on this Forum.
    Thank you
  3. Krishna Hari
    Krishna Hari avatar
    65 posts
    Registered:
    05 Dec 2019
    23 Jan 2020 in reply to Alex
    Link to this post
    I have been using this query below to set the look up value for asrt_ceutypeid_0

     (document).ready(function(){
      function parseQuery(queryString) {
        var query = {};
        var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
        for (var i = 0; i < pairs.length; i++) {
            var pair = pairs[i].split('=');
            query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
        }
        return query;
    }
      var d = parseQuery(window.location.search)["Qs"];
    tpc.forms[0].asrt_ceutypeid_0.set_value("altai_ceutype;d");
    }); 

    but it gives me a console error 

    HTTP500: SERVER ERROR - The server encountered an unexpected condition that prevented it from fulfilling the request. (XHR)POST - https://dev1.asrt.org/PortalConnectorMvc/Services/Data/Lookup/MapValue/e1af9dd1-0c82-6490-b755-ff0000d82291/d

    What am I doing wrong.
  4. Alex
    Alex avatar
    19 posts
    Registered:
    27 Sep 2018
    23 Jan 2020 in reply to Krishna Hari
    Link to this post
    Hello Krishna,
    I think your issue is that  tpc.forms[0].asrt_ceutypeid_0.set_value("altai_ceutype;d"); should be tpc.forms[0].asrt_ceutypeid_0.set_value("altai_ceutype;" + d);
    Give that a try and tell me if anything changed.

  5. Krishna Hari
    Krishna Hari avatar
    65 posts
    Registered:
    05 Dec 2019
    23 Jan 2020 in reply to Alex
    Link to this post
    Yes that fixed it.. Thank you 
5 posts, 1 answered