- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:31 AM
Hi can you help me on this. i know its kind of correct but i think i missed on some steps on the ff scenario for retrieving the value of serial number in the cmbd_ci table. on my client script i did an onchange script were it gives me the value of the serial number but upon setting the value it display as an object not on string.
in my Script Include(SI) here is what i did.
and upon running in my portal this is what i got
on my first alert
on my second alert
what i got on the setvalue is obj which supposed to be the serial number
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:36 AM
Hello
No need to JSON just you can do like below in script include
Remove the JSON and 7th and 15th line script include
return existing.serial_number.toString();
Client script:
remove 17th line and just set the answer to the variable in set value
g_form.setValue('change_request_no',answer);
Hope this helps
Please mark my answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 01:55 AM
i hope your on change variable that is serial_numb contains the serial number but not the sys_id of the cmdb_ci.
What type of field is serial_numb ?
(SI)
getSerialNo: function() {
var sysID = this.getParameter('sysparm_sysID');
var existing = new GlideRecord('cmdb_ci');
existing.addQuery('serial_number',sysID);
existing.query();
if (existing.next()) {
return existing.serial_number.toString();
}
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 02:05 AM
the field of serial_numb is only a single line text.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 02:07 AM
if(newValue!='')
{
var ga = new GlideAjax('SI_for_Generic_CMDB');
ga.addParam('sysparm_name', 'getSerialNo');
ga.addParam('sysparm_sysID', newValue);
ga.getXML(Callback);
}
function Callback(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
alert('my obj-> ' + answer);
g_form.setValue('change_request_no',answer);
}
Hope this helps
please mark my answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 02:11 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:38 AM
Hi,
Few things to modify here.
As you client script is already on the serial_numb variable so you should use newValue
in the script instead of g_from.getValue('serial_numb');
No need to use JSON as there is only one value that needs to be returned. So just return inside if statement like this
if() {
return existing.getValue('serial_number');
}
in the client script just set the answer to change_request_no variable like this.
g_form.setValue('change_request_no',answer);
Regards,
Muhammad
Muhammad