Removing Option from the Choice list

Kaleem A
Giga Guru

Hi All,

I have two fields on the form "Category" and "Subcategory".   Subcategory is dependent on Category field. Here I'm trying to remove the option from the subcategory based on the option selected in the category field.   I have onChange Client script as below. It doesn't seem to be working. Can someone help me on this.

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

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

      return;

    }  

  var incident_category = g_form.getValue('category');

  if(incident_category == 'Proactive'){

  g_form.removeOption('subcategory','system generated');

  }

}

1 ACCEPTED SOLUTION

johansec
Tera Guru

I don't understand why you cannot do this by updating the dependent values in the choice list.



System generated should not be depended on Proactive but instead something else.


View solution in original post

8 REPLIES 8

johansec
Tera Guru

I don't understand why you cannot do this by updating the dependent values in the choice list.



System generated should not be depended on Proactive but instead something else.


When viewing the form you can rightclick on the subcategory field and click show choice list.



Find the label you are looking for as subcategory, I am guessing 'system generated'.



Change the depended value to the correct category it should be associated with.


Hey Corey,



Thanks for the help!. I couldn't do that with the script. Removing the dependent value from subcategory helped us in fixing it.


SudhirOjha
Mega Guru

Why don't you take the option of clearing all and adding in place of using remove option.



use this code. for clearing and adding the options in subcategory.




/***************/


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


if (newValue == '') {


              return;


      }



var submodule = g_form.getValue('u_submodule');


g_form.clearOptions('u_submodule');




if (newValue == 'mod1') {


              g_form.addOption('u_submodule', 'm1crm', 'M1-CRM');


              g_form.addOption('u_submodule', 'm1edi', 'M1-EDI');


              g_form.addOption('u_submodule', 'm1edms', 'M1-Imaging/EDMS');


      }


if (newValue == 'mod2') {


              g_form.addOption('u_submodule', 'm2claims', 'M2-Claims');


              g_form.addOption('u_submodule', 'm2reference', 'M2-Reference');            


      }


    if (isLoading && !g_form.isNewRecord()) {


              g_form.setValue('u_submodule', submodule);


      }



}



/***************/