- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 03:09 PM
How can I get the Serial Number related to the Device Model Variable to auto populate into the Serial Number variable below the device model?
The requested for assets appear in the Device Model (which is in the from the hardware_alm table) but I want the serial number which is coming from the same table to display the device serial number. I would like the related Serial Number variable to auto-populate when the Device Model is selected. How can I accomplish this?
I tried creating a catalog client script but its not working.
Thanks in advance for your help.
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Service Desk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 12:52 PM
student_serial_number needs to be a single line text type variable as it is not referencing a record on a table, rather a field on the record that you already have a reference variable for. Here's an explanation of a way to do this without a script, that I neglected to mention earlier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 04:23 PM
If you want to trigger when Device Model is selected, then your onChange Catalog Client Script should be when Variable name = device_model, or whatever the name of this variable is. The getReference should specify this same variable name in the first parameter. The function argument also needs to be the same as the variable name, so something more like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var SerialNumber = g_form.getReference('device_model', setSerialNumber);
function setSerialNumber(SerialNumber) {
if (SerialNumber) {
g_form.setValue('student_serial_number', SerialNumber.serial_number);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 10:28 AM
Thank you for your response. I tried and it is not working for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 11:34 AM
OK. Help me help you. Did you change 'device_model' to your variable name? And the Variable name field on the script definition is now = to this same variable? What are the variable types of this variable (should be a reference to alm_hardware) and student_serial_number (should be a single line text)? Add some alert('your message here') lines to ensure the script is running and that you are making it inside the if (SerialNumber) block. If all else is well but if (SerialNumber) never evaluates to true, try changing this line to if (SerialNumber.serial_number) { or just take it out since it would just write nothing into the student_serial_number variable if the asset record doesn't have the serial_number field populated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 12:05 PM
This is what I have. I'm a novice at scripting...