onchange client script in catalog form to clear the entered text

Dhanush Rao K
Tera Contributor

Hi 

 

I want to write a client script  for clearing the entered text in variable of catalog item

 

DhanushRaoK_0-1723454811492.png

Whenever we are selecting "others" then "please specify" field will be displayed and we are going to enter the required text.

If we are going to select different option rather than "others" and again selecting "Others" then the previous entered text remains same.

 

Can anyone helpme out to write a Onchange client script for clearing those entered text for the above scenario.

 

Regards,

Dhanush

6 REPLIES 6

Weird
Mega Sage

I believe you could do this with an UI policy checking that Team is changed and by having a ui policy action set the please specify empty with "clear value".

You can also do this with a onChange client script checking the Teams variable and using g_form.clearValue('<please_specify_variable_name>'); or g_form.setValue('<please_specify_variable_name>', '');

Anirudh Pathak
Mega Sage

Hi @Dhanush Rao K ,

Write an "onChange" Client script on change of "Team" variable. Try the below script -

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
	if(newValue != 'others') {
		g_form.clearValue('please_specify');
	}



    //Type appropriate comment here, and begin script below

}

I couldnt able to enter the text in "please specify" field while executing this script

While entering the text it is automatically getting cleared

@Dhanush Rao K ,
Can you share screenshot of how you have written your client script.