Scenario: Check the previous value of state field and if not matches set the field value to current. Can any one explain me this scenario And how to debug it?

IAmIshan
Tera Guru

How to debug the question and solve it?

8 REPLIES 8

 

The Problem is you are running client script on change of the state field and at the same time you are changing the same field so this script is running recursively until the error stops it.

Hi Soumya,

Please use below script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

g_form.addInfoMessage('oldValue: ' + oldValue);

if (oldValue != newValue) {
   //g_form.setValue('state',newValue);// This line is not required because state field is already have new value, do something else
}
else {
alert('Prvoide new State..');
}

g_form.addInfoMessage('newValue: ' + newValue);

}

 

 

As mentioned by Prasad, you are setting setting state value again through the script is making iterative call to same client script which is recursive call and impacting performance.

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Thank You it worked fine for me.

 

Regards,

Soumya

Glad to know that your issue is resolved, could you please close this question by marking appropriate answer as correct answer?

 

This will be helpful for other community member to refer solution in future.

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande