Legacy Dev Forum Posts

 View Only

Sign Up

Data Action String array Contact

  • 1.  Data Action String array Contact

    Posted 06-05-2025 18:45

    kalakshmanakumar | 2024-02-07 16:27:01 UTC | #1

    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


    Jason_Mathison | 2024-02-06 13:42:07 UTC | #2

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


    kalakshmanakumar | 2024-02-06 16:00:35 UTC | #3

    Hi Jason,

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

    Hope I answered your question


    Jason_Mathison | 2024-02-07 19:30:11 UTC | #4

    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


    kalakshmanakumar | 2024-02-13 09:31:26 UTC | #5

    Hi Jason,

    Thanks for your response, i will try it


    system | 2024-03-15 09:31:41 UTC | #6

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