How to Concatenate two Variable field values into another variable in catalog item ?

Rakhesh
Kilo Guru

Hi All,

I want to concatenate two variables , those are select box variable types having with --None--field and mandatory too. When i selecting any of those variables i want to  populate the values into another field. 

How to do that?? If anyone knows give me suggestions

i'm using  onchange script but it applies for only one field.

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var abc= g_form.getDisplayValue('x');
var xyz= g_form.getDisplayValue('y');

g_form.setValue('fieldvalue', abc+ ' ' + xyz+);

 

Regards,

 

Rakesh

 

 

1 ACCEPTED SOLUTION

Hi Rakesh,

Create 2 onChange client scripts using this script. One for X one for Y:-

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var abc= g_form.getDisplayValue('x');
var xyz= g_form.getDisplayValue('y');

g_form.setDisplayValue('targetfieldname', abc+ ' ' + xyz);

}

This should work, if not post more details to get it solved.

Thanks,
Saikiran Guduri (NOW)
Associate Certificate Engineer | ServiceNow Store Apps
(Please mark the answer as correct answer/helpful/accept the solution if it helps)

View solution in original post

8 REPLIES 8

Saikiran Gudur1
Mega Guru

Hi Rakesh,

As per your requirement you should create 2 client scripts (Same script in both). One on variable x, other on y.

Thanks,
Saikiran Guduri (NOW)
(Please mark the answer as correct answer/helpful/accept the solution if it helps)

But only one value is storing another value is not getting

Can you try below code:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var abc= g_form.getValue('x');
var xyz= g_form.getValue('y');

var pqr = abc + ' ' + xyz;

g_form.setValue('fieldvalue', pqr);

 

Thanks
Shashikant

Hit Helpful or Correct on the impact of response.

Hi Rakesh,

Create 2 onChange client scripts using this script. One for X one for Y:-

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var abc= g_form.getDisplayValue('x');
var xyz= g_form.getDisplayValue('y');

g_form.setDisplayValue('targetfieldname', abc+ ' ' + xyz);

}

This should work, if not post more details to get it solved.

Thanks,
Saikiran Guduri (NOW)
Associate Certificate Engineer | ServiceNow Store Apps
(Please mark the answer as correct answer/helpful/accept the solution if it helps)