- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 10:42 AM
Hello Team
I am runing below mention API and getting the output in JSON format and want to get the sysid. How can i get it ?
"items": [ { "className": "cmdb_ci", "operation": "UPDATE", "sysId": "90b9887097c2d110305238271153af1f", "identifierEntrySysId": "fde6803c9782d110305238271153af2f", "identificationAttempts": [ { "info": "sys_object_source SKIPPED", "attemptResult": "SKIPPED", "identifierName": "", "attributes": [], "hybridEntryCiAttributes": [] }, { "attemptResult": "MATCHED", "identifierName": "Configuration Item rule", "attributes": [ "ip_address" ], "hybridEntryCiAttributes": [], "searchOnTable": "cmdb_ci" } ], "info": [], "errorCount": 0, "inputIndices": [ 0 ], "mergedPayloadIds": [], "markers": [], "warningCount": 0 } ], "additionalCommittedItems": [], "relations": [], "additionalCommittedRelations": [], "hasError": false, "hasWarning": false }
How can i get the sysid from this Json format.? Please help.
Solved! Go to Solution.
- Labels:
-
Delegated Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 08:24 PM
Hi,
This is the updated json and this will work
var payload = '{"items":[{"className":"cmdb_ci","values":{"ip_address":"11.11.23.45"}}]}';
var parsed = JSON.parse(payload);
var ip = parsed.items[0].values["ip_address"];
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2022 08:49 AM
I believe this was directed at me... I see you have your answer, but here is my explanation.
The "+ 8" is to set the starting index to the starting point of the sysId. The " + 32" is to set the ending index of the sysId.