How to extract JSON Output from Flow Designer step to Create a record in the Target table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 10:21 PM
Hi All,
I had a business requirement, I want to extract values from JSON and create a record with the data from JSON in Target table.
Parsed JSON with custom action
{
"a": {
"extracted_values": {
"KeyGroups": [],
"_": {
"data": [
{
"is_reviewed": "1",
"metadata": "",
"data": "SBIN0011256",
"target_field": "u_ifc_code",
"key_type": "Text",
"key_id": "17e188b9c30286106001d81bb001317a",
"key_display_name": "IFC Code",
"index": 0,
"availability": "available",
"group_order": "1",
"is_flagged": "0",
"target_record": null
},
{
"is_reviewed": "1",
"metadata": "",
"data": "8563261452630",
"target_field": "u_account_number",
"key_type": "Text",
"key_id": "774976e9c38a46106001d81bb001311c",
"key_display_name": "A/C No.",
"index": 0,
"availability": "available",
"group_order": "0",
"is_flagged": "0",
"target_record": null
}
],
"target_table": "u_extracted_cheque_data"
}
},
"task_id": "0b4bbae9c38a46106001d81bb0013189",
"state": "Processed",
"message": []
}
}
I want extract Account number and IFC code into target table
Thanks in Advance.
Regards,
Haseena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 05:28 AM
who is sending the json? some 3rd party is sending the data?
Didn't get your exact issue?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 05:48 AM
We are having one flow where it will retrieve the values from the record in JSON format.
The JSON which its returning is
{"extracted_values":{"KeyGroups":[],"_":{"data":[{"is_reviewed":"1","metadata":"","data":"SBIN0011256","target_field":"u_ifc_code","key_type":"Text","key_id":"17e188b9c30286106001d81bb001317a","key_display_name":"IFC Code","index":0,"availability":"available","group_order":"1","is_flagged":"0","target_record":null},{"is_reviewed":"1","metadata":"","data":"8563261452630","target_field":"u_account_number","key_type":"Text","key_id":"774976e9c38a46106001d81bb001311c","key_display_name":"A/C No.","index":0,"availability":"available","group_order":"0","is_flagged":"0","target_record":null}],"target_table":"u_extracted_cheque_data"}},"task_id":"0b4bbae9c38a46106001d81bb0013189","state":"Processed","message":[]}
With those data values I need to create a new record with those values in the target table which is not happening.
Regards,
Haseena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 03:29 AM
Please try with the below script :
var parsedJson= JSON.parse(inputJSON); // Please replace inputJSON with your data pill
var keys = parsedJson.a.extracted_values._;
var ifcCode = keys.data[0].data;
var accountNumber = keys.data[1].data;
You can also make use of JSON parser step as mentioned by @Ankur Bawiskar
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.