- 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 12:41 AM
in your script include you are returning the "existing" object.
Please replace it with following line (Line no 20)
return JSON.stringify(existci);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 01:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 12:51 AM
Update your script past as below,
Client script :
var ga = new GlideAjax( 'SI_for_Generic_CMDB');
ga.addParam('sysparm_name', 'getSerialNo');
ga.addParam('sysparm_sysID', newValue);
ga.getXMLAnswer(Callback);
function Callback(response) {
g_form.setValue('change_request_no', response);
}
Script Include :
getSerialNo: function() {
var serialNumber="";
var sysID = this.getParameter('sysparm_sySID');
var existing = new GlideRecord('cmdb_ci');
if (existing.get(sysID)) {
serialNumber= existing.serial_number;
}
return serialNumber;
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 01:54 AM
i tried your code too but it displays on my end as blank