- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 08:44 PM
Hi Team,
As shown below, we receive JSON data from a third party system, and we need to store this data in a custom table.
I have created the import set table and mapping with target table. could you please suggest how to process the Applications [] array related data into the target table fields?
Thanks In advance
JSON Fomat:
{
"u_sys_id": "5f82c76f1b50e1106c1ab9118b4bcb55",
"u_state": "Ready",
"u_comments": "Sample comments",
"u_priority": "High",
"u_correlation_id": "TICKET123456789",
"applications": [
{
"name 1": "value 1",
"name 2": "value 2",
"name 3": "value 3",
"name 4": "value 4",
"name 5": "value 5"
}
]
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2023 02:18 AM - edited 04-24-2023 05:37 AM
I have done achieved the requirement through Scripted REST Api. Thanks All!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 03:06 AM
Hi @sri83 ,
To process the "applications" array related data into the target table fields, you can use a transform map in ServiceNow.
First, create a new transform map and select the import set table as the source table and the target table as the target table.
Next, map the fields in the target table to the corresponding fields in the import set table.
To map the fields in the "applications" array, you will need to create new fields in the target table for each of the "name" fields in the array. For example, if the "applications" array contains "name 1" through "name 5", you would create fields in the target table with the same names.
Then, for each of these fields, you can use a script to extract the corresponding value from the "applications" array. For example, to extract "value 1" from the first element of the "applications" array, you could use the following script:
var apps = source.u_applications;
if (apps && apps.length > 0) {
target.u_name_1 = apps[0]['name 1'];
}
You would need to repeat this for each field in the "applications" array that you want to extract.
Finally, run the transform map to import the data from the import set table into the target table, and the data from the "applications" array should be correctly mapped to the new fields in the target table.
If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the ✅Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.
Thank you!
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2023 08:08 PM - edited 04-23-2023 09:41 PM
Hi Ratnakar,
Thank you somuch for quick reply.
can you please confirm which method needs to use and achieve above requirement in the transform map
Please suggest.
When i am trying to hit the data from REST API Explorer application details are not storing in the table. Please fins the below screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2023 11:40 PM
Hi Team,
Please help and give some suggestion to active this requirement.
Regards,
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2023 11:49 PM
why not use Scripted REST API?
In that parse the json and insert/update the target table records?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader