set a default value of multilinetext type variable based on another selectbox type variable

bijender1
Tera Contributor

Hi, 

We need to set the default value of the "Multi-line text" type variable bassed on another variable of Type " select box". Can you help me in writing that code.

Regards,
B

1 ACCEPTED SOLUTION

kiruthika
Kilo Expert

Hello Bijendar,

 

We could set the "Multi-line text" type variable value based on another variable of Type " select box" using onchange catalog client script.

 

Select the 'Variable name' to specific Select box variable.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var val = g_form.getValue('select_box');  // select_box : variable name of the select box
if(val == 'one'){ 
g_form.setValue('multi_line_text','ONE'); // multi_line_text: variable name of the multiline text

}
else if(val == 'two'){
g_form.setValue('multi_line_text','TWO');
}

}

 

 

Regrads,

Kiruthika Bala

View solution in original post

3 REPLIES 3

AbhishekGardade
Giga Sage

Hello Bijender,

You can write onChange client script to achieve this?

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


g_form.setValue('selectBoxVariableName', 'Multi-line text variable name');

}
}

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade

kiruthika
Kilo Expert

Hello Bijendar,

 

We could set the "Multi-line text" type variable value based on another variable of Type " select box" using onchange catalog client script.

 

Select the 'Variable name' to specific Select box variable.

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var val = g_form.getValue('select_box');  // select_box : variable name of the select box
if(val == 'one'){ 
g_form.setValue('multi_line_text','ONE'); // multi_line_text: variable name of the multiline text

}
else if(val == 'two'){
g_form.setValue('multi_line_text','TWO');
}

}

 

 

Regrads,

Kiruthika Bala

Hi,

 

I tried this but default value is not updating,

My select box variable name is "Team" which have choice as database, network

and mutiline text variable is "ATSDept"

when i run the below code in catalogclient script as below it still not working, please can you check and help me in correcting it.

find_real_file.png