- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2022 01:42 PM
Hi,
So I built a Glide Ajax that allows me to look up a record and return the entire record as an object. Within that record are then other reference fields. In this instance I'm trying to get the sys_id stored in u_item_no, but I'm stuck on how to access it.
Client script funtion is below:
function getOverNightShip() {
var assetLookup = new GlideAjax('TableGlideAjax');
assetLookup.addParam('sysparm_name', 'getRecord');
assetLookup.addParam('sysparm_table', 'alm_hardware');
assetLookup.addParam('sysparm_lookupField', 'ci');
assetLookup.addParam('sysparm_lookupValue', g_form.getValue('cmdb_ci'));
assetLookup.getXML(getDin);
function getDin(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var assetRec = JSON.parse(answer);
alert(String(assetRec.u_item_no));
}
This triggers an alert that shows [Object, Object], if I stringify I can see the contents are
"u_item_no": {
"#text": "fb631006db030014c51df9051d961905",
"@display_value": "211040"
}
Obviously it won't let me do assetRec.u_item_no.#text so how would I go about pulling that value?
Any help is appreciated, thank you.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2022 02:03 PM
I was being stupid, I managed to figure it out...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2022 02:03 PM
I was being stupid, I managed to figure it out...