The CreatorCon Call for Content is officially open! Get started here.

onchange script oldValue not working

Amit Dey1
Tera Contributor

hi , I have written below catalog client script but it is not working

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (oldValue == 'Yes' && newValue == 'No') {
alert('triggering');
g_form.clearValue('variable1');
g_form.clearValue('variable2');
}

I removed oldvalue part then alert is coming but when I removed newvalue part then this alert is not triggering , so that oldvalue is not working , please help me to fix it 

9 REPLIES 9

Community Alums
Not applicable

Hi @Amit Dey1 ,

Can you drop the screenshot of catalog Item ?

Nuwan
Tera Contributor

Hi @Amit Dey1 ,

Can you share screen shots of the variable definition and the client script.

SatyakiBose
Mega Sage

Hello @Amit Dey1 

I have tried the script that you have provided.

The script works perfectly fine for me.

Can you please check if there is any other client script or UI policy defined for the field configured in the client script.

Say for example the client script is configured to run on the change of field - FIELD_1

  • You need to check how many client scripts are there where this field is called in the script.
  • You need to check all the UI policies where this field is used in the UI policy condition, Execute if true & Execute if false scripts, and also in the UI policy actions.
    If you find any, deactivate them and then see how the client script mentioned above works.

Community Alums
Not applicable

HI @Amit Dey1 ,

Tip while working with old, new values:

For an instance, if oldValue=apple & newValue=grape.

after doing some action (newValue=banana) the oldvalue is still apple not grape.

so watch out the field values attentively.