- 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: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:38 AM
Hi
(SI)
getSerialNo: function() {
var sysID = this.getParameter('sysparm_sysID');
var existing = new GlideRecord('cmdb_ci');
var existci = {};
if (existing.get(sysID)) {
existci.serial_number = existing.serial_number.toString();
}
// return JSON.stringify(existing);
return existing.serial_number.toString();
},
(CS)
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 response-> ' + response);
// answer = JSON.parse(answer);
alert('my obj-> ' + answer);
alert('my obj2-> ' + answer.serial_number);
g_form.setValue('change_request_no',answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 01:42 AM
Also let me know the output of the alert('my obj ->'+answer);
(SI)
getSerialNo: function() {
var sysID = this.getParameter('sysparm_sysID');
var existing = new GlideRecord('cmdb_ci');
existing.addQuery('sys_id',sysID);
existing.query();
if (existing.next()) {
return existing.serial_number.toString();
}
},
(CS)
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 01:48 AM