Concatenate two fields into one

Andre8
Giga Guru

Im trying to copy the value of two different fields into one when a value is selected from a reference field.

when a value is selected form a reference field, I would like to push that value along with the value in another field to a field where both values will be concatenated

4 REPLIES 4

_ChrisHelming
Tera Guru

Use an onChange client script on your reference field, get the display value, get the value of your other field, and use g_form.setValue('other_field',val1 + val2); for your final concatenated field. 

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Assuming you have 2 fields

1 - Field A - String

2 - Field B -  Reference

3 - Field C -  This will hold the concatenated value

 

On change of field B write a client script that 

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

  g_form.setValue('<field C>', g_form.getDisplayBox('<field B>').value + ' ' + g_form.getValue('Field A'));
   
}

 

-Anurag

-Anurag

Is Field A editable on the form too? If so, the onChange of Field A should call the same code.

 

Will Field C be editable on the form? If not editable, this whole concatenation should be done in a Business rule on the server side.

 

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Hi Anurag,

 

Can you give me the server side code so on submitting the form the Auto-Number field and the reference field value gets concatenated.

 

Thanks,

Koushik