How ServiceNow can store JSON format?

Imad Nacer2
Tera Contributor

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:

ImadNacer2_1-1668439138508.png

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 :

ImadNacer2_2-1668439228258.png

Is there a way ServiceNow can store this JSON format correctly?

 

4 REPLIES 4

Mohith Devatte
Tera Sage
Tera Sage

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

Imad Nacer2
Tera Contributor

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.

@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?

Roshan Tiwari
Tera Guru

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.