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

Hi Rakesh,

If this content solved your issue/answered the question then please "Accept Solution" so that the question will be moved out from the unanswered list.

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

hi SaiKiran,

i have referred same code, getting error message

 

KishorMudhili_0-1669131717068.png

 

year and Minor/major 

should be dispalyed in Release version.

 

if select release as minor then minor release should be capture .

or 

iif select release as Major then minor release should be capture  in release version. 

PANKAJ MAHTO1
Tera Expert

Hi Rakesh,

Create Multiple Client script for each Fields Data Changes.

Example:- You have 3 Fields and Need to add all 3 Strings in a single field while any one of out of 3 fields changes.

I Have a field called "Name" and three fields value needs to be added "Name" field

A). First Name

B). Middle Name

C). Last Name

Name = "First Name" + "Middle Name" + "Last Name"

So IN this condition I have 3 OnChange Client script on each field changes (First Name, Middle Name, Last Name). So any one of the fields will be changed, NAME field will be auto concatenated.

********************************************************************

OnChange Client Scrip_1

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var firstname = g_form.getDisplayValue('u_first_name');
var middlename = g_form.getDisplayValue('u_middle_name');
var lastname = g_form.getDisplayValue('u_last_name');

g_form.setValue('u_name', firstname + ' ' + middlename + ' ' + lastname);

}

Note:- Similar you have to write 2 more Client scripts for other field changes.

find_real_file.png

 

 

Regards,

Pankaj