How ServiceNow can store JSON format?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2022 07:24 AM
Hi All,
Need a quick help,
I am using Table API to receive data from an external system, the external system is sending data in the below JSON format:
The id attribute is well stored but the u_transcription attribute has been damaged and does not look like an object for further processing although it was sent as an object from the external system :
Is there a way ServiceNow can store this JSON format correctly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2022 07:27 AM
hello @Imad Nacer2 where is the transcription field available ?
if you trying to assign the JSON element u_transcription then stringify it before assigning the value like below
var str = JSON.stringify('your_json');
Hope this helps
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2022 07:37 AM
Thanks @Mohith Devatte for your reply. The "u_transcription" field is a custom field on a custom table. Otherwise I'm using Servicenow's ootb "Table API" so I don't really see a way to do the stringify before assigning the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2022 07:42 AM
@Imad Nacer2 there is a field type called name value pairs which stores the values in JSON format .
Can you try creating that type of field and the assign the JSON directly to that field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2022 10:11 AM
Hi @Imad Nacer2 ,
Please use below code in your script where you have written the script to read ID and Transcription field value:
var a={
"id":"12335",
"u_transit":{
"test":"value"
}
}
var b=a["u_transit"]["test"]
console.log(b)
Note:
This code is just an example to help you, please refer this and write your correct code.