1398 views

Description

When a dropdown (select) box is populated via addOption and -- None -- is added, multiple instances of -- None -- appear in the list even though Unique values only is selected in the variable configuration.

Steps to Reproduce

      1. Navigate to Service Catalog > Catalog Definitions > Maintain Items and click New.

      2. Name the item Choice List Test Portal and click Submit.

      3. Return to the item and under Related Links, got to the Variables tab and click New.

      4. Create the first of two variables and provide the following values:

        Type: Select Box
        Question: choice_list_level1
        Name: choice_list_level1
        Type Specifications: Select Include none

      5. Click Submit.

      6. Return to the catalog item and under Related Links, go to Variables and select the newly created variable.

      7. Under Question Choices, click New and create two question choices, clicking Submit after filling out the required values.

        • Question choice 1:

          Question choice: level1_option1
          Text: level1_option1
          Value: option1

        • Question choice 2:

          Question choice: level1_option2
          Text: level1_option2
          Value: option2

      8. Create the second variable and provide the following values:

        Type: Select Box
        Question: choice_list_level2
        Name: choice_list_level2
        Type Specifications: Select Include none and Unique values only

      9. Click Submit.

      10. Return to the catalog item and under Related Links, go to Variables and select the newly created variable.

      11. Under Question Choices, click New and create two question choices, clicking Submit after filling out the required values.

        • Question choice 1:

          Question choice: Option1 selected
          Text: Option1 Selected
          Value: option1

        • Question choice 2:

          Question choice: Option2 selected
          Text: level1_option2
          Value: option2

      12. Add a Catalog Client Script to populate choice_list_level2 based on the choice selected for choice_list_level1:

        Name: choice list test portal; 
        Type: onChange
        Variable name: choice_list_level1
        Script code:

        function onChange(control, oldValue, newValue, isLoading) {
        if (isLoading || newValue == '') {
        g_form.clearOptions('choice_list_level2');
        g_form.addOption('choice_list_level2', '', '-- None --');
        g_form.addOption('choice_list_level2', 'option1_value', 'Option1 Selected');
        g_form.addOption('choice_list_level2', 'option2_value', 'Option2 Selected');
        }

        var selected = g_form.getValue('choice_list_level1');

        if(selected == 'option1')
        {

        g_form.clearOptions('choice_list_level2');
        g_form.addOption('choice_list_level2', '', '-- None --');
        g_form.addOption('choice_list_level2', 'option1_value', 'Option1 Selected');
        }

        if(selected == 'option2')
        {
        g_form.clearOptions('choice_list_level2');
        g_form.addOption('choice_list_level2', ' ', '-- None --');
        g_form.addOption('choice_list_level2', 'option2_value', 'Option2 Selected');
        //g_form.setValue("choice_list_level2","");
        }
        }

      13. Access the item on the Service Catalog item page.

        Note that the the list displays correctly: When you select level1_option1 from choice list level1, choice list level2 shows a single entry of -- None --.

      14. On Service Portal, access the Choice List Test Portal page.

        Note that there are two -- None -- entries in the drop-down list (one is added from the script).

        When you select level1_option1 from choice list level1, choice list level2 shows three -- None -- entries.

        The same issue occurs on Lookup Select Box variable types as well, with multiple --None-- values displayed in the drop-down list even when Include none and Unique values only are selected in the variable settings.

 

Workaround

Add a space in the second parameter for addOption(), for example:

g_form.addOption('choice_list_level2', ' ', '-- None --');


Related Problem: PRB714724

Seen In

Helsinki Patch 2
Helsinki Patch 5
Helsinki Patch 6 Hot Fix 1
Helsinki Patch 7

Fixed In

Helsinki Patch 10

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2017-10-11 17:07:52
Published:2017-01-10