combine 2 single line text variable into 1 single line text variable

TMKAM
Tera Contributor

how to combine 2 single line text variable into 1 single line text variable after requester input both 2 single line text variable 

scenario as per below

1. requester input single line text variable A and single line text variable B

2. automatically show single line text variable C information which has both information variable A and variable B.

1 ACCEPTED SOLUTION

Karan Chhabra6
Mega Sage

Hi @TMKAM ,

 

You need to write two onChange catalog client scripts, one on variable A and second on variable B

Client Script 1 : onChange of var A

KaranChhabra6_0-1687146931399.png

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
var strB = g_form.getValue('var_b');
var strConc = newValue +  ' ' + strB;

g_form.setValue('var_c', strConc );
   
}

 

Client script 2: onChange of var B

KaranChhabra6_1-1687146985415.png

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

    var strA = g_form.getValue('var_a');
    var strConc = strA + ' ' + newValue;
    g_form.setValue('var_c', strConc);


}

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!

View solution in original post

2 REPLIES 2

Ravi Chandra_K
Kilo Patron

You can write on change client script on Variable B. You can add two variables and populate the same on Variable C.

Below is the sample script 

g_form.setValue('variable_c') = g_form.getValue('variable_A') + "" + g_form.getValue('variable_B');

 

Karan Chhabra6
Mega Sage

Hi @TMKAM ,

 

You need to write two onChange catalog client scripts, one on variable A and second on variable B

Client Script 1 : onChange of var A

KaranChhabra6_0-1687146931399.png

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
var strB = g_form.getValue('var_b');
var strConc = newValue +  ' ' + strB;

g_form.setValue('var_c', strConc );
   
}

 

Client script 2: onChange of var B

KaranChhabra6_1-1687146985415.png

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

    var strA = g_form.getValue('var_a');
    var strConc = strA + ' ' + newValue;
    g_form.setValue('var_c', strConc);


}

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!