Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Preserve indexes when using nested arrays in Data Actions

    Posted 5 hours ago

    Hi everyone!

    I'm working with a Genesys Cloud Data Action that returns nested arrays, for example:

    {
      "companies": [
        {
          "document": "12345678000100",
          "accounts": [
            { "number": 10001 },
            { "number": 10002 }
          ]
        },
        {
          "document": "98765432000100",
          "accounts": [
            { "number": 20001 }
          ]
        }
      ]
    }

    I need to access the accounts dynamically while preserving their relationship with the parent company, e.g.:

    companies[0].accounts[0]
    companies[0].accounts[1]
    companies[1].accounts[0]

    However, when I expose the nested properties through the Data Action Output Contract/Translation Map, there are limitations.

    My workaround was to return the entire API response as a raw string and then convert it to JSON inside Architect, which preserves the original JSON structure.

    Has anyone found a way to configure the Output Contract + Translation Map so that companies[*].accounts[*] preserves the relationship between the parent and child indexes?

    Thanks!


    #DataActions

    ------------------------------
    Daniel Souza
    ------------------------------


  • 2.  RE: Preserve indexes when using nested arrays in Data Actions

    Posted 3 hours ago

    Hi Daniel,

    From what I understand, the limitation here is specifically around flattening nested arrays for Architect. Genesys has confirmed previously that flattening does not support nested arrays, and Architect uses the flattened Data Action output.

    So preserving a structure such as:

    companies[n].accounts[m]

    through the normal flattened output becomes problematic.

    Your workaround of returning the raw JSON as a string and then using JsonParse() in Architect is actually an approach that has been discussed previously in the Genesys Developer Community. In that discussion, Jason Mathison from Genesys confirmed that this was how he would handle the scenario. (Genesys Community)

    Previous discussions:

    https://community.genesys.com/discussion/api-is-returning-data-but-architect-errors-out-when-trying-to-print-the-data

    https://community.genesys.com/discussion/data-action-returning-json-in-success-template

    Hopefully someone else from the Community who has handled a similar nested parent/child structure can add their experience or another approach as well.

    Hope this helps!



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    ------------------------------