web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Multi Select Checkbox

(0) ShareShare
ReportReport
Posted on by

Hi all,

I am trying to create a multi select text box based on the code on this page: http://msdynamicscrm4all.blogspot.in/2011/12/how-create-multi-select-option-set-in.html

I have created the option set which is called wis_health and the multi line text box called wis_healthmulti

I am unsure what to change on the code. Can anyone advise what I need to put in for each value?

For example, should my values be for

  • var_new_optionset
  • var_new_optionsetvalue
  • OS
  • OSV

// var_new_optionset >>  Provide schema-name for Option Set field
// var_new_optionsetvalue >> Provide schema-name for field which will store the multi selected values for Option Set
// OS >> Provide Option Set field object
// OSV >> Provide text field object which will store the multi selected values for Option Set

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mithilesh Kumar Profile Picture
    10,047 on at
    RE: Multi Select Checkbox

    Hi there,

    There is nothing to change in the code. The code is a generic code.

    However, you need to pass the parameters carefully and they should be in correct order as per the image below

    2605.1-_2D00_-Copy.jpg

    Parameters

    1. Option Set field schema name (something like "new_optionsetname")
    2. Multi Line Text schema name (something like "new_textname")
    3. Object of the Option Set field
    4. Object of the Multi Line Text field

    Hope that helps

    Thanks

    Please mark my post as verified if you found it helpful

  • Community Member Profile Picture
    on at
    RE: Multi Select Checkbox

    Thank you for your help but this has not resolved my issue. I left the JavaScript as below and then added my OnLoad and OnSave events.

    My schema names are:

    • Option Set - wis_health
    • Multi Line Text box - wis_HealthMulti

    My parameters for OnLoad:

    "wis_Health","wis_HealthMulti", document.all.wis_Health, document.all.wis_HealthMulti

    My parameters for OnSave:

    document.all.wis_Health, "wis_HealthMulti"

    When you please explain what you mean by 'Object of the Option Set field' and 'Object of the Multi Line Text field'? And do I need to do anything with this?

    Thank you for your help :)

    // var_new_optionset >>  Provide schema-name for Option Set field
     // var_new_optionsetvalue >> Provide schema-name for field which will store the multi selected values for Option Set
     // OS >> Provide Option Set field object
     // OSV >> Provide text field object which will store the multi selected values for Option Set
    //Method to convert an optionset to multi select Option Set
     function ConvertToMultiSelect(var_new_optionset, var_new_optionsetvalue, OS, OSV)
     {
    if( OS != null && OSV != null )
     {
       OS.style.display = "none";
       Xrm.Page.getControl(var_new_optionsetvalue).setVisible(false);
      // Create a DIV container
       var addDiv = document.createElement("<div style='overflow-y:auto; height:80px; border:1px #6699cc solid; background-color:#ffffff;' />");
       OS.parentNode.appendChild(addDiv);
      // Initialise checkbox controls
       for( var i = 1; i < OS.options.length; i++ )
       {
         var pOption = OS.options[i];
         if( !IsChecked( pOption.text , OS, OSV) )
           var addInput = document.createElement("<input type='checkbox' style='border:none; width:25px; align:left;' />" );
         else
           var addInput = document.createElement("<input type='checkbox' checked='checked' style='border:none; width:25px; align:left;' />" );
        var addLabel = document.createElement( "<label />");
         addLabel.innerText = pOption.text;
        var addBr = document.createElement( "<br/>"); //it's a 'br' flag
        OS.nextSibling.appendChild(addInput);
         OS.nextSibling.appendChild(addLabel);
         OS.nextSibling.appendChild(addBr);
       }
     }
     }
    
    ///////Supported functions
      // Check if it is selected
       function IsChecked( pText , OS, OSV)
       {
         if(OSV.value != "")
         {
           var OSVT = OSV.value.split(";");
           for( var i = 0; i < OSVT.length; i++ )
           {
             if( OSVT[i] == pText )
               return true;
           }
         }
         return false;
       }
      // var_new_optionsetvalue >> Provide schema-name for field which will store the multi selected values for Option Set
       // OS >> Provide Option Set field object
       // Save the selected text, this field can also be used in Advanced Find
       function OnSave(OS, var_new_optionsetvalue)
       {
         var getInput = OS.nextSibling.getElementsByTagName("input");
         var result = '';
        for( var i = 0; i < getInput.length; i++ )
         {
           if( getInput[i].checked)
           {
             result += getInput[i].nextSibling.innerText + ";";
           }
         }
        //save value
         control = Xrm.Page.getControl(var_new_optionsetvalue);
         attribute = control.getAttribute();
         attribute.setValue(result);
      }


  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at
    RE: Multi Select Checkbox

    Hi..

    try this mahadeomatre.blogspot.com/.../convert-dropdown-pick-list-option-set.html

    I have radio button  list..same way you can create check box list.

  • Community Member Profile Picture
    on at
    RE: Multi Select Checkbox

    I have not been able to resolve my issue, can someone please help?

  • Suggested answer
    Mithilesh Kumar Profile Picture
    10,047 on at
    RE: Multi Select Checkbox

    Hi Lou,

    What problem are you facing. I can create a Multi select Option Set using the example from the Blog.

    May I know the version of browser you are using as "document.all" method has been deprecated.

    You should use document.getElementById, but it will be an unsupported customization.

    For On Load

    "<OptionSetFieldName>", "<MultiTextFieldName>", document.getElementById("<optionsetfieldname>"), document.getElementById("<multiseletctfieldname>")

    For On Save
    document.getElementById("<optionsetfieldname>"), "<MultiTextFieldName>"


    However, this will be an Unsupported Customization.

    Hope that helps

    Thanks

    Please mark my post as verified if you found it helpful

  • Community Member Profile Picture
    on at
    RE: Multi Select Checkbox

    Thank you for your response but I am still having no luck. Nothing happens. The option set drop down still displays.

    I am using IE11.

    I have added the js below. I have set the parameters for:

    OnLoad

    "wis_health", "wis_healthmulti", document.getElementById.wis_health, document.getElementById.wis_healthmulti

    OnSave

    document.getElementById.wis_health,"wis_healthmulti"

    wis_health = option set

    wis_healthmulti = text box

    I would greatly appreciate any suggestions as I am not able to figure out why it won't work..?? Have I missed something - do I need to change the js file at all??

    // var_new_optionset >>  Provide schema-name for Option Set field
     // var_new_optionsetvalue >> Provide schema-name for field which will store the multi selected values for Option Set
     // OS >> Provide Option Set field object
     // OSV >> Provide text field object which will store the multi selected values for Option Set
    //Method to convert an optionset to multi select Option Set
     function ConvertToMultiSelect(var_new_optionset, var_new_optionsetvalue, OS, OSV)
     {
    if( OS != null && OSV != null )
     {
       OS.style.display = "none";
       Xrm.Page.getControl(var_new_optionsetvalue).setVisible(false);
      // Create a DIV container
       var addDiv = document.createElement("<div style='overflow-y:auto; height:80px; border:1px #6699cc solid; background-color:#ffffff;' />");
       OS.parentNode.appendChild(addDiv);
      // Initialise checkbox controls
       for( var i = 1; i < OS.options.length; i++ )
       {
         var pOption = OS.options[i];
         if( !IsChecked( pOption.text , OS, OSV) )
           var addInput = document.createElement("<input type='checkbox' style='border:none; width:25px; align:left;' />" );
         else
           var addInput = document.createElement("<input type='checkbox' checked='checked' style='border:none; width:25px; align:left;' />" );
        var addLabel = document.createElement( "<label />");
         addLabel.innerText = pOption.text;
        var addBr = document.createElement( "<br/>"); //it's a 'br' flag
        OS.nextSibling.appendChild(addInput);
         OS.nextSibling.appendChild(addLabel);
         OS.nextSibling.appendChild(addBr);
       }
     }
     }
    
    ///////Supported functions
      // Check if it is selected
       function IsChecked( pText , OS, OSV)
       {
         if(OSV.value != "")
         {
           var OSVT = OSV.value.split(";");
           for( var i = 0; i < OSVT.length; i++ )
           {
             if( OSVT[i] == pText )
               return true;
           }
         }
         return false;
       }
      // var_new_optionsetvalue >> Provide schema-name for field which will store the multi selected values for Option Set
       // OS >> Provide Option Set field object
       // Save the selected text, this field can also be used in Advanced Find
       function OnSave(OS, var_new_optionsetvalue)
       {
         var getInput = OS.nextSibling.getElementsByTagName("input");
         var result = '';
        for( var i = 0; i < getInput.length; i++ )
         {
           if( getInput[i].checked)
           {
             result += getInput[i].nextSibling.innerText + ";";
           }
         }
        //save value
         control = Xrm.Page.getControl(var_new_optionsetvalue);
         attribute = control.getAttribute();
         attribute.setValue(result);
      }
    


  • Suggested answer
    Mithilesh Kumar Profile Picture
    10,047 on at
    RE: Multi Select Checkbox

    Hi Lou,

    Your parameter passing needs modification, you missed out the brackets after getElementById.

    OnLoad

    "wis_health", "wis_healthmulti", document.getElementById("wis_health"), document.getElementById("wis_healthmulti")

    OnSave

    document.getElementById("wis_health"),"wis_healthmulti"

    Hope that helps

    Thanks

  • Community Member Profile Picture
    on at
    RE: Multi Select Checkbox

    Still no joy, it is puzzling me. Using individual check boxes will not work for me :( there are far too many options to choose from.

    I am getting this error when I open the form:

    The health field turns out blank:

    These are my new parameters:

    Thanks Mithilesh I really appreciate your help.

  • Suggested answer
    Mithilesh Kumar Profile Picture
    10,047 on at
    RE: Multi Select Checkbox

    Hi Lou,

    As stated earlier, this is an unsupported customizations and may fail anytime. This used to work earlier but some functions/method have been deprecated.

    Starting IE 9, createElement method does not support angular brackets. You need to changes them as follows

    OLD

    var addDiv = document.createElement("<div style='overflow-y:auto; height:80px; border:1px #6699cc solid; background-color:#ffffff;' />");

    NEW

    var addDiv = document.createElement("div");

    addDiv.HTML = "<div style='overflow-y:auto; height:80px; border:1px #6699cc solid; background-color:#ffffff;' />";

    Similar changes for other createElement method in the code as well.

    I would just you not to perform any unsupported customizations. This can fail anytime.

    May I know your actual requirement, maybe there are some supported workaround.

    Hope that helps

    Thanks

  • Community Member Profile Picture
    on at
    RE: Multi Select Checkbox

    We need to track issues related to a person. There are several different categories with several issues related to that category. Each person can have several issues in each category.

    A supported workaround to this would be great.

    Thanks

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans