Legacy Dev Forum Posts

 View Only

Sign Up

Fetchify Address Output Transformation - Success Template

  • 1.  Fetchify Address Output Transformation - Success Template

    Posted 06-05-2025 18:43

    Chris_Carr | 2022-11-01 20:39:25 UTC | #1

    Hello,

    I am after some assistance as I have exhausted all ideas and attempts to achieve my desired outcome.

    I've configured a data action that connects to Fetchify for UK address validation:

    The API is working fine and the JSON result is being returned as per the example below

    The problem I have is I'm having issues trying to amend the Genesys output response to put all the returned addresses into one list variable (rather than several variables). In order to do this, I'm trying to create a bespoke output response. The default is this:

    { "deliverypoints": [ { "organisationname": "", "departmentname": "", "line1": "24 GREYHOUND HILL", "line2": "", "udprn": "17708604", "dps": "1B" }, { "organisationname": "", "departmentname": "", "line1": "26 GREYHOUND HILL", "line2": "", "udprn": "17708605", "dps": "1D" } ], "deliverypointcount": 2, "postalcounty": "GREATER LONDON", "traditional_county": "MIDDLESEX", "town": "LONDON", "postcode": "NW4 4JP" }

    I would like the response template to format the address like line_1, line_2, postal_county, traditional_county, town, postcode so that I can create a dropdown in a script if possible.

    Something like this for example.

    So far, I can only create one variable to grab all entities' line 1 values using the following success template

    { "translationMap": { "line1": "$.deliverypoints[*].line1" }, "translationMapDefaults": { "line1": "None" }, "successTemplate": "{ \"line1\": ${line1}}" }

    Here is an example of the resolved template map

    "line_1": "[ \"24 GREYHOUND HILL\", \"26 GREYHOUND HILL\", \"28 GREYHOUND HILL\", \"30 GREYHOUND HILL\", \"32 GREYHOUND HILL\", \"34 GREYHOUND HILL\", \"36 GREYHOUND HILL\", \"40 GREYHOUND HILL\", \"42 GREYHOUND HILL\", \"44 GREYHOUND HILL\", \"46 GREYHOUND HILL\", \"48 GREYHOUND HILL\", \"50 GREYHOUND HILL\", \"38 GREYHOUND HILL\", \"22 GREYHOUND HILL\" ]"

    The applied output transformation

    { "line_1": [ "24 GREYHOUND HILL", "26 GREYHOUND HILL", "28 GREYHOUND HILL", "30 GREYHOUND HILL", "32 GREYHOUND HILL", "34 GREYHOUND HILL", "36 GREYHOUND HILL", "40 GREYHOUND HILL", "42 GREYHOUND HILL", "44 GREYHOUND HILL", "46 GREYHOUND HILL", "48 GREYHOUND HILL", "50 GREYHOUND HILL", "38 GREYHOUND HILL", "22 GREYHOUND HILL" ] }

    Here is the configuration of my action.

    Inputs

    { "type": "object", "properties": { "key": { "type": "string" }, "postcode": { "type": "string" }, "response": { "type": "string" } }, "additionalProperties": true }

    Outputs

    { "type": "object", "properties": { "deliverypoints": { "type": "array", "items": { "type": "object", "properties": { "organisationname": { "type": "string" }, "departmentname": { "type": "string" }, "line1": { "type": "string" }, "line2": { "type": "string" }, "udprn": { "type": "string" }, "dps": { "type": "string" } }, "additionalProperties": true } }, "deliverypointcount": { "type": "integer" }, "postalcounty": { "type": "string" }, "traditional_county": { "type": "string" }, "town": { "type": "string" }, "postcode": { "type": "string" } }, "additionalProperties": true }

    Thank you very much and look forward to hearing any ideas.


    Jason_Mathison | 2022-11-15 16:14:43 UTC | #2

    Hi Chris,

    Your action basically seems to work if you replace your response configuration with the default of

    { "translationMap": { }, "translationMapDefaults": { }, "successTemplate": "${rawResult}" }

    This will returned a flattened version of the response, that looks like:

    { "deliverypoints.departmentname": [ "", "" ], "deliverypoints.udprn": [ "17708604", "17708605" ], "postalcounty": "GREATER LONDON", "deliverypoints.organisationname": [ "", "" ], "town": "LONDON", "deliverypointcount": 2, "traditionalcounty": "MIDDLESEX", "deliverypoints.dps": [ "1B", "1D" ], "postcode": "NW4 4JP", "deliverypoints.line2": [ "", "" ], "deliverypoints.line1": [ "24 GREYHOUND HILL", "26 GREYHOUND HILL" ] }

    Which for tools like architech or scripts would end up being variables like deliverypoints.line1 which contain lists of values, like

    "deliverypoints.line1": [ "24 GREYHOUND HILL", "26 GREYHOUND HILL" ]

    --Jason


    Chris_Carr | 2022-11-03 18:41:43 UTC | #3

    Hi Jason,

    Thank you, I think I understand what you are saying and makes sense. I am going to give this a go and confirm.

    Thank you.

    Kind Regards, Chris Carr


    system | 2022-12-04 18:42:00 UTC | #4

    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: 16988