202 views

Description

Clearing and adding options to a choice field multiple times in a client script does not work as expected.

Steps to Reproduce

 

  1. Navigate to any Catalog item for ex. Report an Issue Catalog item
  2. Right click on New Variable, and create two new variables with following details:
    1. Search Term – Single line text
    2. Module – Select Box
  3. Configure Catalog Client Script with following details
    1. Name – Test Script for search
    2. UI Type – All
    3. Type – onChange
    4. Variable_name – search_request
    5. Script

function onChange(control, oldValue, newValue, isLoading) {

   if (isLoading || newValue == '') {

    g_form.clearOptions('module'); 

      return;

   }

   g_form.addOption('module','1','One');

   g_form.addOption('module','2','Two');

}

 

Purpose of the script: - If there is any value in Search Term then module should get populated with Options. If search term is empty, then Module options should be empty.

 

Actions taken: - Populate search term with ABC then make it empty and again populate it with ABC

Expected: - Module variable should get populated with Options.

Actual: -  Module variable does not get populated with Options.

Reason: - clearOptions works only once and does not work second time.

Workaround

Use removeOption(fieldName, value) method instead of clearOptions method. (For more information, see GlideForm - Client.)

For ex. 

 g_form.removeOption('module','One');
 g_form.removeOption('module','Two');

Related Problem: PRB719371

Seen In

Fuji Patch 13 Hot Fix 1

Fixed In

Helsinki Patch 10
Istanbul Patch 6
Jakarta

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-06-19 18:19:37
Published:2018-01-08