Genesys Cloud - Developer Community!

 View Only

Sign Up

Expand all | Collapse all

Assistance Required: Retrieving Dynamic Object from Data Action

  • 1.  Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-10-2025 08:06

    Dear Genesys Developer Community,

    I hope you are doing well.

    I am reaching out to seek guidance on an issue I am encountering while attempting to retrieve dynamic objects from a Data Action within a workflow/Architect flow. Below are the steps I have followed:

    Steps Taken:

    1. Created a Data Action to retrieve contact information using contactID and contactListID. The Data Action is designed to fetch details from a contact list in an object format.

    2. Defined ContactData as an object in the contracts output section to store the retrieved contact details.

    3. Used the following schema to structure the output:

      {
        "translationMap": {
          "contactData": "$.data"
        },
        "translationMapDefaults": {
          "contactData": "UNKNOWN"
        },
        "successTemplate": "{\r\n  \"contactData\": ${contactData} \r\n}"
      }

    4. Successfully retrieved the entire data object inside the raw result, storing it in the ContactData object.

    5. Saved and published the Data Action.

    6. Invoked the Data Action inside a workflow/Architect flow, but the output section is not display.

    Issue:

    • The Data Action does not return the expected dynamic object when used inside the workflow.

    • I intend to reuse this Data Action to dynamically fetch contact details, but currently, it only shows the input contact.

    Request for Assistance:

    Has anyone encountered a similar issue? How can I ensure that the Data Action correctly returns the dynamic object inside the workflow? Any suggestions or best practices would be greatly appreciated.

    I appreciate your time and support and look forward to your insights.


    #Architect
    #DataActions
    #Triggers

    ------------------------------
    Thanks,
    Balaji Balakrishnan
    ------------------------------


  • 2.  RE: Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-11-2025 10:27

    Architect requires that there be an output contract with specific data types.  If the output response is dynamic the I suggest you have a single "string" returned in your output contract. In your data action take the existing response and json escape it. Then in architect you can unescape that string into JSON and work with it as JSON.



    ------------------------------
    --Jason
    ------------------------------



  • 3.  RE: Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-12-2025 08:59

    Nice...



    ------------------------------
    George Ganahl GCCX-AI, GCP, GCSME, ICCE, ICHD, etc.
    Technical Adoption Champion
    Genesys
    2024 Community Member of the Year
    ------------------------------



  • 4.  RE: Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-12-2025 09:39

    Hi Jason Mathison,

    If I set the ContactData as a String type in the contracts section, I am unable to store the entire object inside ContactData. My intention is to store the entire data object and use it from Architect.

    Could you suggest an approach to achieve this while ensuring the full object is retained?



    ------------------------------
    Balaji Balakrishnan
    ------------------------------



  • 5.  RE: Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-12-2025 09:54

    You can use this macro to convert the JSON object into a string:

    $esc.jsonEncode(): Use this method to escape JSON's reserved characters in the output. It allows JSON to be stored in a string form.

    https://help.mypurecloud.com/articles/velocity-macros-data-actions/



    ------------------------------
    --Jason
    ------------------------------



  • 6.  RE: Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-12-2025 10:35
    Thanks for your quick response,
    It's works!

    ---
    Thanks,
    Balaji B 





  • 7.  RE: Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-12-2025 22:55

    Great.



    ------------------------------
    Arulazhagan Ezhini
    ------------------------------



  • 8.  RE: Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-13-2025 04:23

    I am trying a similar data-action but something not working.
    I run the get-conversation API in data-action and want to convert all the results into architect where i can then process it as JSON, but I surely am missing something. Any help would be really appreciated.

    Input: /api/v2/conversations/calls/${input.ConversationID}

    Output: JSONString (type string)
    Data Action Response : 

    {
      "translationMap": {
      },
      "translationMapDefaults": {
      },
      "successTemplate": "{\"JSONString\": $esc.jsonEncode(${rawResult}) }"
    }
    Error I get:
    Apply output transformation: Transform failed to process result using 'successTemplate' template due to error:'Unexpected character ('\' (code 92)): was expecting double-quote to start field name at [Source: (String)"{"JSONString": {\n \"id\" : \"462772cc-8072-47f4-90e2-d6a07d8ca659\",\n \"participants\" : [ {\n \"id\" : \"b1d01c83-19e5-4476-8dda-67bcf4e95443\",\n \"name\" : \"Mobile Number, United Kingdom\",\n \"address\" : \"tel:+440000000000\",\n \"startTime\" : \"2025-06-13T07:41:02.207Z\",\n \"connectedTime\" : \"2025-06-13T07:41:02.432Z\",\n \"endTime\" : \"2025-06-13T07:50:28.341Z\",\n \"purpose\" : \"customer\",\n \"state\" : \"terminated\",\n \"direction\" : \"inbound\","[truncated 20986 chars]; line: 1, column: 17]' Template:'{"JSONString": $esc.jsonEncode(${rawResult}) }'.


    ------------------------------
    Vineet Kakroo
    Senior Technical Consultant
    ------------------------------



  • 9.  RE: Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-13-2025 09:45
    Looks like this
    successTemplate": "{\"JSONString\": $esc.jsonEncode(${rawResult}) }"
    might need escaped quotes around the encoded JSON like this:
    successTemplate": "{\"JSONString\": \"$esc.jsonEncode(${rawResult})\" }"


    ------------------------------
    --Jason
    ------------------------------



  • 10.  RE: Assistance Required: Retrieving Dynamic Object from Data Action

    Posted 06-13-2025 10:43

    Thanks Jason. This worked perfectly.



    ------------------------------
    Vineet Kakroo
    Senior Technical Consultant
    ------------------------------