Forums

Forums / Developing Portals / How to set / display a default value in a picklist?

How to set / display a default value in a picklist?

Thread is closed for posting
3 posts, 1 answered
  1. eva.braun
    eva.braun avatar
    39 posts
    Registered:
    12 Feb 2015
    30 Nov 2016
    Link to this post
    I would like to have a picklist displayed with a default value. How can that be done?

    Use case in short: the default value should trigger the rules manager to hide fields, which are only required once the default value is changed.

  2. Missing user
    Missing user avatar
    Answered
    02 Dec 2016 in reply to eva.braun
    Link to this post
    Hi Eva,

    You can use the following code sample to set a default value to pick list when form loads. Please add a javascript widget to your form, place the code below after changing the pick list developer name, and set the placement by the body closing tag.
     

    $(window).load(function()
    {
    var picklistvalue=$find($(".CrmPicklist_C022").attr("id")).get_value();

    if(picklistvalue=="")
    {
    $find($(".CrmPicklist_C022").attr("id")).set_value(put here the numeric value number from CRM of the desired default option value from your options sets);
    }
    });


    After you have placed the code on the form, you need to use a rule manager where you can simply set the criteria about what to do when option set field value change and​ which section you would like to hide.

    If you find any problem to implement the code above or set the rule manager, please join me on free live Q/A session and our team will be happy to assist you. To register on Q/A session, please click on this link and select a day/time.

    https://www.crmportalconnector.com/developer-network/training


    Thanks
    Syed



  3. eva.braun
    eva.braun avatar
    39 posts
    Registered:
    12 Feb 2015
    07 Dec 2016 in reply to Missing user
    Link to this post
    Hi Syed,

    Hero. That has done the trick. Thank you so much.
3 posts, 1 answered