Clear variable onChange

Sam Ogden
Tera Guru

Hi All,

On our record producer we have a variable called 'u_prod'.  This is a lookup select box which is a list of product models.

I have the following onChange catalog client script.  If the answer to u_prod is "Mobile App" it should set the value of the variable 'more_detials_answer' to "mobile_app' .  If the answer is not "Mobile App" it should clear the value in more_details_answer.

The script is correctly setting the value when I select the option of Mobile App.  If I then change the answer in u_prod thought it is not clearing the value.

Any suggestions where I am going wrong?

Thanks

find_real_file.png

1 ACCEPTED SOLUTION

Munender Singh
Mega Sage

Hi,

Kindly use:

g_form.setValue('more_details_answer','');

 

Regards,

Munender

View solution in original post

5 REPLIES 5

Shiraz2
Mega Guru

See if the below works:

 

for your else statement:

g_form.setValue instead of g_form.clearValue

Hi,

I've amended the script, but this is still not working:

//Scrpt to set variable to the value of the answer in classic_data

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || oldValue) {
      return;
   }
	var prod = g_form.getValue('u_prod');   
	alert(prod);
		if(prod == ("Mobile App")){
		g_form.setValue('more_details_answer', 'mobile_app'); 
	}
	else {
		g_form.setValue('more_detials_answer',"");
}
}

When I select 'Mobile App' in the u_prod (Please choose the affected CDL product from the following list) variable it is populating 'mobile_app' in the more_details (Hidden - More Detials Answer) variable as I want.  If I then change the answer for u_prod to anything else it is not clearing more_details_answer as I require.  I've exposed the more_details_answer field which is normally hidden:

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

Any further suggestions?

I've pasted in the line from sunny11 response directly and this seems to have worked.

Thanks

Munender Singh
Mega Sage

Hi,

Kindly use:

g_form.setValue('more_details_answer','');

 

Regards,

Munender