How to populate one field with information from 2 fields?

astanley
Tera Contributor

Hello all,

I am trying to populate 4 fields on my catalog item with information from the user record. find_real_file.pngThese four fields I have highlighted are all fields that should be populated with information. The "office" field is a reference field for the cmn_location table. The last field, "Phone Number", and is meant to populate information from 2 fields on the sys_user table: business phone and business phone extension with a space and an 'x' between (i.e. 999-999-9999 x9999). The business phone field contains the phone number (ex. 999-999-9999) and the business phone extension contains the extension number (ex. 9999).  The way I have my script set up now just calls the business phone. So the field auto-populates like this: 999-999-9999. My goal is to have all of these fields populated, with the last field being populated with information from two fields. How can I achieve this? Please review my script below:

function onChange(control, oldValue, newValue, isLoading) {

var id = g_form.getValue('ConfirmInfoReqName');

var user = new GlideRecord('sys_user');

user.addQuery('sys_id',id); user.query();

if ( user.next() ) {

g_form.setValue('title', user.title);

g_form.setValue('office_employee', user.location);

g_form.setValue('user_id', user.user_name);

g_form.setValue('phone_number', user.phone);

}

}

(If a picture is easier, see below)

find_real_file.png

Also, which variable does this catalog client script apply to? I am very new with scripting, any assistance would be greatly appreciated.

11 REPLIES 11

@astanley Did you try this?

Best Regards
Aman Kumar

sonali panda1
Kilo Sage
You should use script include and a client script