Copy the response body of the import set api to new table

Prakash Pareek
Tera Expert

Hi , Could you please tell how can i copy the response body (which we will get when we hit the import set api) to another table .

ex: { "import_set": "ISET29325654",

"staging_table": "ABC",

"result": [

{ "transform_map": "ABC Transform Map",

"table": "sc_task",

"display_name": "number",

"display_value": "SCTASK0815512",

"record_link": "https://ABC/api/now/table/sc_task/93a4a9999bc6c610f41811b5bb4bcbb0",

"status": "error",

"sys_id": "93a4a9999bc6c610f41811b5bb4bcbb0",

"status_message": "Ignored: System could not find the Catalog Task: SCTASK0815512 in ServiceNow", "error_message": "This catalog task may not belong to catalog item. Please provide a valid catalog task" }

]

}

This is the response (and this response is different each time AND depends upon the sctask number ) .. now i want this response to be saved in another table's particular field .. Kindly please help me !!! Thank you ...

9 REPLIES 9

dgarad
Tera Sage

Hi @Prakash Pareek 

 try the below code to save reponse .

var grTicket = new GlideRecord('table name');
grTicket.initialize();
grTicket.setValue('tablefileld name', responsbody);
grTicket.insert();

Hi @dgarad  could you please suggest how i will get the responsebody  field that you have used in setValue in the code

Hi @Prakash Pareek 

where you hit the import set API.

Hi @dgarad from postman i am hitting an import set api for a staging table called ABC that will map with sctask table 

POST https://demo.service-now.com/api/now/import/ABC

 with sctask number as mandatory and valid sctask number