onChange catalog client script is executed twice

Ro5
Tera Expert

Hello.
I created an onChange catalog client script that, when a variable on a portal form is changed, returns it to its original value if the condition does not apply.
However, when I executed it, I found that it was being executed multiple times for some reason. Does anyone have any idea what the cause is?

onChange target variable name: linkage

script:
var priceTrigger = g_form.getValue('price_trigger');
if (priceTrigger == 'false' && newValue == "necessary") {
alert("Revert to original value!");
g_form.setValue('linkage', 'unnecessary');
}

Regards,
Ro

1 ACCEPTED SOLUTION

Ro5
Tera Expert

I received a message from support saying that this issue may be a bug and will file a problem case.
Therefore, I will close this question.
Thank you to everyone who responded.

View solution in original post

2 REPLIES 2

Harish Bainsla
Kilo Patron
Kilo Patron

hi try below code

var priceTrigger = g_form.getValue('price_trigger');
var linkageValue = g_form.getValue('linkage');

if (priceTrigger == 'false' && newValue == 'necessary' && linkageValue !== 'unnecessary') {
alert("Revert to original value!");
g_form.setValue('linkage', 'unnecessary');
}

Ro5
Tera Expert

I received a message from support saying that this issue may be a bug and will file a problem case.
Therefore, I will close this question.
Thank you to everyone who responded.