How to extract JSON Output from Flow Designer step to Create a record in the Target table

Haceena Shaik
Tera Expert

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

 

7 REPLIES 7

@Haceena Shaik 

who is sending the json? some 3rd party is sending the data?

Didn't get your exact issue?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

 

We are having one flow where it will retrieve the values from the record in JSON format.

SS2.png

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

Amit Verma
Kilo Patron
Kilo Patron

Hi @Haceena Shaik 

 

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;

 

AmitVerma_0-1716287323612.png

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.