- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 10:59 AM
Hello Experts,
I have a requirement to auto fill user's phone number from caller's profile on the Incident form, how can I populate caller's 'Business Phone' number from the user's profile automatically when the Caller is selected?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 06:17 PM
Hi James,
As previously mentioned, the simplest approach is to model your solution after the base platform incident client script '(BP) Set Location to User'. This script runs client-side 'onChange' for field 'Caller'. It essentially gets the referenced user's location and copies it to the location field on the form. This use-case is pretty simple since both the source and target fields are a reference type and do not require any formatting.
It is possible to use the same approach for a phone number, but depending on your requirements for localization/normalization, the answer is a bit more complicated..
If you plan on using the base platform field "sys_user.phone) as your source, this column is of type 'Phone Number' (ph_phone). This can easily be mapped to a string type field, however you will not have the basic formatting capabilities on the incident form. It is technically possible to create a column with the legacy ph_phone type to enable one-to-one mapping with basic formatting, but I would recommend reaching out to ServiceNow for guidance as this field type is not readily available to customers.
Here's a sample of what an incident client script could look like as an 'onChange' type for field 'Caller' assuming your source field is named 'phone' and target field is 'u_contact_number'.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
g_form.setValue('u_contact_number', '');
return;
}
if (!g_form.getControl('u_contact_number')) {
return;
}
var caller = g_form.getReference('caller_id', setContactNumber);
}
function setContactNumber(caller) {
if (caller) {
g_form.setValue('u_contact_number', caller.phone);
}
}
If you plan on using a source or target field that is an E.164 Phone Number, I would recommend reviewing the docs and community posts regarding usage as the E.164 field type can be a bit difficult to setup and utilize in certain cases.
Thanks,
Aric

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 11:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 11:22 AM
Thanks Rajiv,
however, how can I re-lable the field from 'business phone' to 'Contact Number' without changing it globally?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 11:54 AM
Hi James,
You can try dictionary override.
BR
Rajiv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 12:06 PM