Genesys Cloud - Developer Community!

 View Only

Sign Up

Expand all | Collapse all

Array value as output in Data Action

  • 1.  Array value as output in Data Action

    Posted 05-12-2025 12:00

    Hi, 

    I am trying to save array value as output in Data action.. However i am not able to do so.

    Attaching below screenshot of JSON. I need the Flow.State values 


    #DataActions

    ------------------------------
    Vipul Gamit
    Senior Engineer, Telecom
    ------------------------------


  • 2.  RE: Array value as output in Data Action

    Posted 05-12-2025 12:00

    Below is my current response 

    {
      "translationMap": {
        "State": "$.outputData"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\n \"State\":${State} \n}"
    }


    ------------------------------
    Vipul Gamit
    Senior Engineer, Telecom
    ------------------------------



  • 3.  RE: Array value as output in Data Action

    Posted 05-12-2025 12:20

    Full JSON :

    {
      "flowVersion.inputSchema.description": "Schema defining flow input parameters.  Property names map to flow scoped variables marked as a flow input.  If you do not supply a property value for an input variable, the variable value will be set to the initial value configured on it in the flow at flow startup.",
      "outputData.Flow.test": [
        "New York",
        "Delhi",
        "Surat",
        "Gujarat",
        "Gurgaon"
      ],
      "flowVersion.generationId": "WORKFLOW_VERSION_PUBLISHED",
      "flowVersion.supportedLanguages.language": [
        "en-us"
      ],
      "flowVersion.inputSchema.definitions.archString.oneOf.description": [
        "A NOT_SET String value.",
        "A character string.  Examples: \"\", \"Hello\", \"Just say \\\"No!\\\"\""
      ],
      "flowVersion.inputSchema.properties.Flow__State.type": "array",
      "flowVersion.name": "5.0",
      "flowVersion.inputSchema.properties.Flow__test.maxItems": 2000,
      "flowVersion.outputSchema.properties.Flow__State.maxItems": 2000,
      "id": "85a98f4d-4f0c-4720-821b-db827cd5ed37",
      "flowVersion.debug": false,
      "flowVersion.inputSchema.type": "object",
      "flowVersion.outputSchema.properties.Flow__test.maxItems": 2000,
      "flowVersion.inputSchema.properties.Flow__test.items.$ref": "#/definitions/archString",
      "flowVersion.commitVersion": "5.0",
      "flowVersion.configurationVersion": "2.0",
      "flowVersion.outputSchema.additionalProperties": false,
      "flowVersion.datePublished": "2025-05-12T07:33:00.980Z",
      "flowVersion.dateCreated": 1747035180921,
      "flowVersion.inputSchema.$schema": "http://json-schema.org/draft-07/schema#",
      "flowVersion.outputSchema.type": "object",
      "dateLaunched": "2025-05-12T11:22:12.986Z",
      "flowVersion.configurationUri": "/api/v2/flows/2236dc2a-5783-4536-ac68-433f3fd1318e/versions/5.0/configuration",
      "flowVersion.inputSchema.properties.Flow__test.type": "array",
      "flowVersion.createdBy.id": "6fa2726f-2fae-4a35-9703-18c7cf1552ac",
      "flowVersion.outputSchema.definitions.archString.oneOf.description": [
        "A NOT_SET String value.",
        "A character string.  Examples: \"\", \"Hello\", \"Just say \\\"No!\\\"\""
      ],
      "flowVersion.outputSchema.description": "Schema defining flow output parameters.  Property names map to flow scoped variables marked as a flow output.",
      "name": "Instance Mon May 12 11:22:12 UTC 2025",
      "flowVersion.inputSchema.title": "Flow input schema",
      "flowVersion.inputSchema.definitions.archString.oneOf.maxLength": [
        null,
        32000
      ],
      "status": "COMPLETED",
      "flowVersion.inputSchema.definitions.archString.oneOf.type": [
        "null",
        "string"
      ],
      "flowVersion.dateSaved": 1747035179340,
      "flowVersion.supportedLanguages.isDefault": [
        true
      ],
      "flowVersion.inputSchema.properties.Flow__State.items.$ref": "#/definitions/archString",
      "flowVersion.outputSchema.properties.Flow__State.type": "array",
      "completionReason": "Success",
      "outputData.Flow.State": [
        "New York",
        "Delhi",
        "Surat",
        "Gujarat",
        "Gurgaon"
      ],
      "flowVersion.outputSchema.properties.Flow__test.items.$ref": "#/definitions/archString",
      "dateCompleted": "2025-05-12T11:22:13.104Z",
      "flowVersion.outputSchema.$schema": "http://json-schema.org/draft-07/schema#",
      "flowVersion.secure": false,
      "flowVersion.inputSchema.additionalProperties": false,
      "flowVersion.outputSchema.definitions.archString.oneOf.type": [
        "null",
        "string"
      ],
      "flowVersion.outputSchema.title": "Flow output schema",
      "selfUri": "/api/v2/flows/executions/85a98f4d-4f0c-4720-821b-db827cd5ed37",
      "flowVersion.id": "5.0",
      "flowVersion.outputSchema.properties.Flow__test.type": "array",
      "flowVersion.dateCheckedIn": 1747035180929,
      "flowVersion.outputSchema.definitions.archString.oneOf.maxLength": [
        null,
        32000
      ],
      "flowVersion.outputSchema.properties.Flow__State.items.$ref": "#/definitions/archString",
      "flowVersion.selfUri": "/api/v2/flows/2236dc2a-5783-4536-ac68-433f3fd1318e/versions/5.0",
      "flowVersion.createdBy.selfUri": "/api/v2/users/6fa2726f-2fae-4a35-9703-18c7cf1552ac",
      "flowVersion.inputSchema.properties.Flow__State.maxItems": 2000,
      "flowVersion.outputSchema.definitions.archString.archDataTypeId": "str",
      "flowVersion.inputSchema.definitions.archString.archDataTypeId": "str"
    }



    ------------------------------
    Vipul Gamit
    Senior Engineer, Telecom
    ------------------------------



  • 4.  RE: Array value as output in Data Action

    Posted 05-12-2025 19:55
    Edited by Anton Vroon 05-12-2025 19:56

    Assuming your output contract is accepting an array.

    Try updating your json path to:  $["outputData.Flow.test"]

    You don't have a property just called outputData and your properties have dots in them so you have to make those absolute values.

    Edit: JsonPath is your friend:

    vs



    ------------------------------
    Anton Vroon
    ------------------------------



  • 5.  RE: Array value as output in Data Action

    Posted 05-13-2025 03:00

    Can you help me with the response as I tried with the value you suggested still not working..



    ------------------------------
    Vipul Gamit
    Senior Engineer, Telecom
    ------------------------------



  • 6.  RE: Array value as output in Data Action

    Posted 05-13-2025 03:43

    Use following and store response in string output contract.

    {
      "translationMap": {
        "Filter1": "$.outputData.Flow.test"
      },
      "translationMapDefaults": {},
      "successTemplate": "{ \"Filter1\": \"$esc.jsonString(\"${Filter1}\")\" }"
    }

    In your architect flow, use JsonParse to convert string to JSON.



    ------------------------------
    Parvez Alam
    ------------------------------



  • 7.  RE: Array value as output in Data Action

    Posted 05-13-2025 08:35

    I want to use the variable on script so needed as array output 



    ------------------------------
    Vipul Gamit
    Senior Engineer, Telecom
    ------------------------------



  • 8.  RE: Array value as output in Data Action

    Posted 05-13-2025 10:40
    Edited by Dan Fontaine 05-13-2025 15:18

    When I did this in a Script, I had to create a Data Action to use the Genesys Cloud API to get all the rows in a Data Table so that I could create a drop-down list in a Script. The Data Table held the Keys and Values needed to create a drop-down list. Where the Keys were displayed as the options in the list that the agent would select, and the Values were the values for the drop-down list items.

    In the script, I created two List of Strings variables to hold the Key values and the Value values and then I ran the Data Action on page load and assigned the Keys to a Keys List of Strings variable (array) and the Values to a Values List of Strings variable (array).

    The GET Request URL Template is /api/v2/flows/datatables/${input.datatableId}/rows?pageSize=500&showbrief=false

    The input is the data table ID

    The output is:

    {
      "type""object",
      "additionalProperties"true,
      "properties": {
        "QueueInfo": {
          "type""array",
          "items": {
            "type""object",
            "additionalProperties"true,
            "properties": {
              "Key": {
                "type""string"
              },
              "Value": {
                "type""string"
              }
            }
          }
        }
      }
    }

    Admittedly, it has been a while since I built this, but please provide some additional details or questions.



    ------------------------------
    Dan Fontaine
    C1
    ------------------------------



  • 9.  RE: Array value as output in Data Action

    Posted 05-13-2025 14:10

    Hi Dan,

    this kind of worked .. However I need to use the output on dropdown in script and it coming as a,b,c,d,e  any way i can get as below in script drop down

    a

    b

    c



    ------------------------------
    Vipul Gamit
    Senior Engineer, Telecom
    ------------------------------



  • 10.  RE: Array value as output in Data Action

    Posted 05-13-2025 14:31

    I got it working .. Thanks you guys!!



    ------------------------------
    Vipul Gamit
    Senior Engineer, Telecom
    ------------------------------



  • 11.  RE: Array value as output in Data Action

    Posted 05-13-2025 14:58

    It would be helpful if you provided "how", so future searchers can find it.



    ------------------------------
    Paul McGurn
    Senior Manager, Telecom & DevOps
    Persistent Systems
    ------------------------------



  • 12.  RE: Array value as output in Data Action

    Posted 05-13-2025 15:14

    Hi,

    I used the below Output JSON

    The output is:

    {
      "type""object",
      "additionalProperties"true,
      "properties": {
        "QueueInfo": {
          "type""array",
          "items": {
            "type""object",
            "additionalProperties"true,
            "properties": {
              "Key": {
                "type""string"
              },
              "Valuel": {
                "type""string"
              }
            }
          }
        }
      }
    }
    And on script I mapped the array to list string variable and in drop down. I used the name list as drop down, select the drop-down container in  script and on the right hand configuration pane change the Options drop down from List to Variable then select the List String Variable assigned 


    ------------------------------
    Vipul Gamit
    Senior Engineer, Telecom
    ------------------------------