Legacy Dev Forum Posts

 View Only

Sign Up

How to get the Array list as Data Action Output in architect call flow

  • 1.  How to get the Array list as Data Action Output in architect call flow

    Posted 06-05-2025 18:41

    AnilKumarN | 2019-05-17 13:24:25 UTC | #1

    Hi, we are sending a request and getting a response as below ,

    Input Contract:- =======================

    {

    "$schema": "http://json-schema.org/draft-04/schema#",

    "type": "object",

    "required": [

    "clientId",

    "zone",

    "web",

    "phoneNumber"

    ],

    "properties": {

    "clientId": {

    "type": "string"

    }, "zone": {

    "type": "string"

    },

    "web": {

    "type": "string"

    },

    "phoneNumber": {

    "type": "string"

    }

    }

    }

    =============================== output contract:- =============================== { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "negativeAniInfoList": { "type": "array", "items": [ { "type": "object", "properties": { "id": { "type": "integer" }, "phoneNumber": { "type": "string" }, "type": { "type": "string" }, "createdBy": { "type": "string" }, "created": { "type": "string" }, "lastChangeDate": {88 "type": "string" } } } ] }, "aniMatchStatus": { "type": "string" }, "aniInfoLIst": { "type": "array", "items": {} } } } ================================ Response:- ================================ [ { "aniInfoList": [], "negativeAniInfoList": [ { "id": 4, "phoneNumber": "102173545", "type": "Blocked", "createdBy": "ABCDEF", "created": "2019-03-25T19:50:00.000+0000", "lastChangeDate": "2019-03-25T19:50:00.000+0000" } ], "aniMatchStatus": "RED", "aniNegFlag": true } ] =================================== We are able to get the response as Json Objects and when we try to use these values in Architect Call flow we are able to get the Output only which are not json Arrays i.e., we are able to get only aniMatchStatus , aniNegFlag but we are not able to get the negativeAniInfoList Json Array Objects . Kindly help us out to achieve this to get the Array list as Data Action Output in architect call flow .

    Thanks Anil


    Jason_Mathison | 2019-05-17 14:12:49 UTC | #2

    Hi Anil,

    A couple of things. First, would it be possible for you to export the action and post that? You will need to replace any sensitive information, for example the URL may be something you want to replace with foo.com.

    Second, the response that you posted is wrapped in an array [ ], however your output contract indicates that it is expecting an object at the outermost layer. You may need to use firstFromArray to pull the object out of the array you are getting as a response: https://help.mypurecloud.com/articles/velocity-macros-data-actions/#firstFromArray

    --Jason


    AnilKumarN | 2019-05-17 18:03:49 UTC | #3

    Please find the link for the action export {{LINK REMOVED}}


    tim.smith | 2019-05-17 18:04:35 UTC | #4

    Please take care sharing config information on the forum. The file you shared publicly contains an API key that you need to regenerate now since it has been leaked.


    AnilKumarN | 2019-05-17 18:07:55 UTC | #5

    Its Dev API , we will change after the issue resolved.


    Jason_Mathison | 2019-05-17 18:12:26 UTC | #6

    Hi Anil,

    I was able to grab your action export (and alerted Tim to remove the link). The output contract looks completely different on the export than what you posted above. Is this the same action, or have you made a lot of changes to it?

    Either way, can you post an up-to-date example of the result you get from step 8 "Execute" in test mode. Feel free to overwrite any sensitive output with * or whatever.

    --Jason


    AnilKumarN | 2019-05-20 09:20:46 UTC | #7

    Hi team ,

    This action contains multiple array list ,we are unable to get the actions array list output in architech call FLOW. We are unable to upload the .json action so composing the same below .

    { "name": "GetAgentCustomerContact - Exported 2019-05-20 @ 14:42", "integrationType": "custom-rest-actions", "actionType": "custom", "config": { "request": { "requestUrlTemplate": "https://xxx.com", "requestType": "POST", "headers": { "x-api-key": "xxxx" }, "requestTemplate": "{\"ctxParm\": { \"clientId\":\"99\", \"zone\": \"5\",\"web\":\"false\"}, \"partyId\":${input.partyId}, \"clientPartyId\":${input.clientPartyId}}" }, "response": { "translationMap": { "mobilePhoneNumber": "$.mobilePhoneNumber", "emailAddress": "$.['emailAddress']", "contractCount": "$.contractCount", "brand1": "$.contractList[].brand", "contractType": "$.contractList[0].contractType", "contractId": "$.contractList[0].contractId", "contractType1": "$.contractList[].contractType", "contractId1": "$.contractList[].contractId", "reinsurer": "$.contractList[0].reinsurer", "reinsurer1": "$.contractList[].reinsurer", "brand": "$.contractList[0].brand" }, "translationMapDefaults": {}, "successTemplate": "{\r\n \t\"contractCount\": ${contractCount},\r\n \t\"mobilePhoneNumber\": ${mobilePhoneNumber},\r\n \t\"contractType\": ${contractType},\r\n \t\"contractId\": ${contractId},\r\n \t\"brand\": ${brand},\r\n \t\"reinsurer\": ${reinsurer},\r\n \t\"contractId\": ${contractId},\r\n\"emailAddress\": ${emailAddress}\r\n,\r\n\"contractType1\": ${contractType1}\r\n,\r\n\"contractId1\": ${contractId1}\r\n,\r\n\"reinsurer1\": ${reinsurer1}\r\n,\r\n\"brand1\": ${brand1}\r\n} " } }, "contract": { "input": { "inputSchema": { "$schema": "xxx/schema", "type": "object", "required": [ "clientId", "zone", "web", "partyId", "clientPartyId" ], "properties": { "clientId": { "type": "string" }, "zone": { "type": "string" }, "web": { "type": "string" }, "partyId": { "type": "string" }, "clientPartyId": { "type": "string" } } } }, "output": { "successSchema": { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "required": [ "contractType", "contractId", "brand", "reinsurer" ], "properties": { "contractType": { "type": "string" }, "contractId": { "type": "string" }, "brand": { "type": "string" }, "reinsurer": { "type": "string" } } } } }, "secure": false }


    AnilKumarN | 2019-05-20 10:18:33 UTC | #8

    Hi team ,

    We tried using firstFromArray but it is fetching only first element . But our output is something like this "contractType1": [ "LIFECAD", "Life2", "LIFE3" ] We need all the output in the call flow architect i.e., we need to play these contract type to customer one by one or we prompt if the user is interested to listen the contract type after playing the first . if yes we need to play 2nd contract type . How can we achieve this in call flow (Architect)


    Jason_Mathison | 2019-05-20 16:04:11 UTC | #9

    Hi Anil,

    Please post an up-to-date example of the result you get from step 8 "Execute" in test mode. Feel free to overwrite any sensitive output with * or whatever.

    For your questions about how to create your flow please start a new thread in the architect room explaining what exactly you are hung up on.

    --Jason


    AnilKumarN | 2019-05-23 14:44:43 UTC | #10

    Hi Jason,

    Please find below response we are getting : { "contractCount": 3, "emailAddress": "abc@yahoo.com", "mobilePhoneNumber": "1111111111", "contractList": [ { "contractType": "LIFECAR", "contractId": "90421222", "brand": "XXXXXX", "reinsurer": "ABCD0" }, { "contractType": "LIFECAT", "contractId": "12345678", "brand": "XXXXXX", "reinsurer": "ABCD1" }, { "contractType": "LIFEMAD", "contractId": "12345677", "brand": "XXXXXX", "reinsurer": "ABCD2" } ] }


    Jason_Mathison | 2019-05-23 19:15:05 UTC | #11

    In order to get the arrays for contractType you are going to need to include a string array in your output contract to put the contents of contractType1 into. Architect will only provide access to variables defined in your output contract.

    So you would need to add something like this to your output contract: "contractTypes": { "type": "array", "properties": { "items": { "type": "string" } } }

    and something like this to your response template:

    ,\r\n\"contractTypes\": ${contractType1}\r\n

    I also had to remove this from your output contract because the action was configured to return things not included in your output contract: "additionalProperties": false


    system | 2019-06-23 19:15:07 UTC | #12

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 5174