OnChange client script is not working in RITM level?

Shantharao
Kilo Sage

Hello All,,

City is select box varibale, it contains below  two choices 

ABC

DEF

State is another select box it contains below choices

abc1

abc2

abc3

abc4

 

In the city variable on selection of ABC, I want to keep abc1 & abc2  and want to remove abc3 & abc4, This scenario is working on catalog form but not working on RITM level, but I have ticked/checked both catalog Item view and requested item view check boxes for this onchange client script

 

var loc = g_form.getValue("location_required_requisition");

if(loc == "ABC"){
g_form.removeOption("state","abc1");
g_form.removeOption("state","abc2");
}
else{
g_form.addOption("state","abc1","ABC1");
g_form.addOption("state","abc2","ABC2");

g_form.addOption("state","abc3","ABC3");
g_form.addOption("state","abc4","ABC4");
}

7 REPLIES 7

var loc = g_form.getValue("location_required_requisition");

if(loc == "ABC"){
g_form.removeOption("state","abc1");
g_form.removeOption("state","abc2");
}
else{
g_form.addOption("state","abc1","ABC1");
g_form.addOption("state","abc2","ABC2");

g_form.addOption("state","abc3","ABC3");
g_form.addOption("state","abc4","ABC4");
}

robertsduca
Giga Contributor

what version  / patch are you on? the new sc_formv2 api (introduced in Kingston)that has done some interesting things with catalog client scripts and methods that formally worked in Jakarta especially when using ajax to add/clear options.

Here was the info we received from HI Support on a very similar issue where we were calling category / subcategory values from an options table, via ajax and they were being reset onLoad when looking at the variables from the RITM record.

Despite what was recommended below we decided to go with option 1 since we did not want to impact the entire catalog by disabling sc_formv2.

 

issue described in PRB1309031 which showed up in Kingston and London but has been fixed in Madrid.

The PRB states that Adding an option that is already the selected value changes the selected value to the first option available. This is what happens in your case. After the values are cleared, in Jakarta if the same value that was selected is added back, the selection is retained but in Kingston and London, the selection is lost and the form shows None as the selected value since that is the first option in the field.

As I mentioned above, the PRB has been fixed in Madrid and upgrading to Madrid should resolve the issue for you.

There are 2 workarounds listed as well:

Add a conditional statement before the option is added to verify the current value of the field and the option you're trying to add do not match.

Alternatively, you can create this property: Name: glide.sc.use_sc_form_v2 Type: True/False Value: False

With the first workaround, you might need to modify the script in a way that the options are not cleared out first i.e. the g_form.clearOptions would need to be removed and also you would not need to add the None option since it comes with the variable itself by default. Then while adding the options in the loop, you can verify that the option being added is not the one that already exists.

The second workaround may have some other impacts as this workaround was provided to get around a lot of PRBs in Kingston which have since been fixed therefore my recommendation would be to go with the first one till you are able to upgrade to Madrid.

 

Slava Savitsky
Giga Sage

Although this does not answer your question directly, I would like to point out that you could use reference qualifiers instead of trying to modify choice lists on the fly if you had Cities and States recorded in the Locations hierarchy.