Display value from field in above reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 06:06 PM
Hi
I have a reference field that looks up a computer in alm_hardware table.
I want to display the serial number 'serial_number' in a form of the computer selected in the above reference field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 06:25 PM
Hi,
You'd have to change the "display" value for that table to be the serial number field.
This is a platform wide change (meaning wherever else references to this table are used, serial number would display there as well) and would be done by accessing the dictionary record for that table and then setting the display column to "true" for the relevant field.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2022 06:43 AM
Hi Adam,
I hope my reply above was at least Helpful, even if it confirmed a change you wouldn't want to make, haha.
Take care! 🙂
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 08:20 PM
I agree with point shared by Allen.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2022 11:32 PM
Hi Adam,
Add a read-only field "Serial Number" (name:serial_number) to the form below computer field.
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ajax = new GlideAjax('AlmHardware');
ajax.addParam('sysparm_name', 'getSerialNumber');
ajax.addParam('sysparm_sys_id', newValue);
ajax.getXMLAnswer(function(answer) { // call script include
alert(answer);
if (answer.length > 0) {
g_form.setValue('serial_number', answer); // set serial number to field "serial number"
}
});
}
Script Include. Name: AlmHardware
var AlmHardware = Class.create();
AlmHardware.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSerialNumber: function() {
var sysId = this.getParameter('sysparm_sys_id');
var grHardware = new GlideRecord('alm_hardware');
if (grHardware.get(sysId)) {
return grHardware.serial_number;
}
return;
},
type: 'AlmHardware'
});
Execution result: