How to populate one field with information from 2 fields?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 01:57 PM
Hello all,
I am trying to populate 4 fields on my catalog item with information from the user record. These 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)
Also, which variable does this catalog client script apply to? I am very new with scripting, any assistance would be greatly appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 10:19 PM
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2022 02:19 PM