Set Select Box variable value in onChange script

dp11
Tera Guru

Below is a screenshot of an onChange script where I am attempting to set the value of a Select Box type variable based on value selected in a Multiple Choice type variable.

Desiring the below:

1) When osc_node_res_action (Multiple Choice type) value is 'new'
        osc_node_res_magnetic_flag (Select Box type) should be set to 'Yes'

2) When osc_node_res_action (Multiple Choice type) value is 'modify'
        osc_node_res_magnetic_flag (Select Box type) should be set to 'No Change'

I tried using the setValue method first but that had no effect. Then I tried the addOption method which works on the catalog form. But after item submission if I simply refresh the RITM form, there is an alert indicating 

"Changes you made may not be saved" with choices to Leave or Cancel.

Also, the value of osc_node_res_magnetic_flag (Select Box type) in the RITM's Variable tab does not change as desired.

NOTE: I have experimented with unchecking the "Applies on Requested Items" and "Applies on Catalog tasks" checkboxes and still the above two behaviors are the same

find_real_file.png

 

Or is there any other way I can effect the desired value changes?

Thanks!

KaMmILa__
Tera Expert

are the values for Yes and No correct ? i mean lower case or upper case ?

Yes, the casing is correct. Thanks!

Harika Bhupathi
Giga Guru

Hi @dp

 

Try below code, it should work

if (isLoading || newValue == 'new') {
        g_form.setValue('osc_node_res_magnetic_flag', 'yes');
        return;
	}
    else if (isLoading || newValue == 'modify') {
        g_form.setValue('osc_node_res_magnetic_flag', 'no change');
    }

find_real_file.png

Please mark my answer correct/helpful, if it resolved your issue

 

Regards,

Harika

Thanks for your reply. That code doesn't work. There is no effect upon selecting 'modify' for osc_node_res_action