Data Action String array Contact

Hi,

I would like to contact String array in data action and response as one field output. Is there a way to do it ?

{
    "translationMap": {
        "State": "$.recentTransfers[*].state",
        "TransferType": "$.recentTransfers[*].transferType"
    },
    "translationMapDefaults": {
        "State": "[]",
        "TransferType": "[]"
    },
    "successTemplate": "{\"StateTransferType\": ${StateTransferType}}"
}

In the above script I would like to send "StateTransferType" field response as "State"+"TransferType".

State Array:
Complete
Canceled
Complete
Canceled

TransferType Array:
Attended
UnAttended
Attended
UnAttended

Output Array:
Complete - Attended
Canceled - UnAttended
Complete - Attended
Canceled - UnAttended

Is there some kind of reasonable limit to how large the state and TransferType arrays might be?

Hi Jason,

Thanks for your response
State and transferType array max is 10 and minimum is 0 or 1

Hope I answered your question

So here is a configuration that will handle up to 4 items, you can expand it as far as you want to go by adding more

#if($state_array.size() > 3), \" $state_array[3] - $TransferType_array[3]\"#end

sections to it, by incrementing the size check and [x] values.

{
  "translationMap": {
    "State": "$.recentTransfers[*].state",
    "TransferType": "$.recentTransfers[*].transferType"
  },
  "translationMapDefaults": {
    "State": "[]",
    "TransferType": "[]"
  },
  "successTemplate": "#set ($state_array = $State.replaceAll(\"\\[|\\]| |$esc.quote\", \"\").split(',')) #set ($TransferType_array = $TransferType.replaceAll(\"\\[|\\]| |$esc.quote\", \"\").split(',')) {\"StateTransferType\" : [ #if($state_array.size() > 0) \"$state_array[0] - $TransferType_array[0]\"#end #if($state_array.size() > 1), \" $state_array[1] - $TransferType_array[1]\"#end #if($state_array.size() > 2), \" $state_array[2] - $TransferType_array[2]\"#end #if($state_array.size() > 3), \" $state_array[3] - $TransferType_array[3]\"#end]}"
}

--Jason

Hi Jason,

Thanks for your response, i will try it

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