- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2017 08:49 PM
HI Team,
Please help me to fetch the sys_id value from json object
"parent":"",
"made_sla":"true",
"caused_by":"",
"watch_list":"",
"upon_reject":"cancel",
"sys_updated_on":"2017-05-26 03:35:02",
"sys_id":"33acf340db4b320050315ec0cf96193f",
"contact_type":"",
"correlation_id":"",
"location":"",
"category":"inquiry"
}
}
Thanks
Chandu Telu
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2017 03:16 AM
Hi,
Use below code to parse JSON data
var data = '{ "result":{ "parent":"", "sys_id":"33acf340db4b320050315ec0cf96193f", "contact_type":"",}}'; // Demo json Data
var jsData= JSON.parse(data); // convert json object into javascript object
var sysID = jsData["result"].sys_id ;
Thanks,
Jeet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2017 08:57 PM
Hi Chandu, I may just be getting confused by the output, but the fact that you have two pairs of curly braces (i.e. { } ) makes it seem like result is possibly contained within another object. If result.sys_id or result['sys_id'] both do not work then I would be looking for a way to get the name of the object which contains result. If this isn't helpful, please provide some context on what you have done to get the above output and how you are trying to consume it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2017 08:57 PM
Hello Chandu,
Refer the below threads may helpful to you.
How to get the Change Request's sys_id inside a Business Rule's Script?
How to check nested json object value in sysparm_query?
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2017 02:52 AM
Assuming you're storing the json object somewhere so i'm going to call it obj in this example:
var obj = {
"parent":"",
"made_sla":"true",
"caused_by":"",
"watch_list":"",
"upon_reject":"cancel",
"sys_updated_on":"2017-05-26 03:35:02",
"sys_id":"33acf340db4b320050315ec0cf96193f",
"contact_type":"",
"correlation_id":"",
"location":"",
"category":"inquiry"
}
};
var sysID = obj.result.sys_id;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2017 03:11 AM
Hi,
You can do this by storing the Response in Object and then Dot walkin as mentioned below:
var object = {
"parent":"",
"made_sla":"true",
"caused_by":"",
"watch_list":"",
"upon_reject":"cancel",
"sys_updated_on":"2017-05-26 03:35:02",
"sys_id":"33acf340db4b320050315ec0cf96193f",
"contact_type":"",
"correlation_id":"",
"location":"",
"category":"inquiry"
}
};
To get Sys Id use the Below syntax:
var id = object.sys_id;
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke