Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Extract Dynamic List of a JSON Array using Data Action and Architect

    Posted 4 hours ago

    Hi Folks,

    Goal: I am trying to fetch Primary Contact details, dynamic array of JSON, of active users using a data action. For that, I added EmailAddress, Names as Array of String Output Contracts and PrimaryContacts as Array of JSON array, to fetch the dynamic array of JSON objects for each contact. It will help me to get and navigate Primary Contacts easily for each user. Because, I don't have exact count of the Primary contacts for each user. I thought if I get the list of JSON array then easily with JSON parsing I can get my required parameter values inside flow. 

    Result: When I am running the Data Action with unchecked the Flatten, I can see Username, EmailAddresse(Attached) as expected but PrimaryContactDetails are blank array(Attached). But, in execution and output transformation step it shows as a List of JSON array. Actually, the Primary contacts are dynamic, a JSON array, are not showing in result display(Attached). As, it was not giving me any error in Data Action, I thought to fetch the list in Architect if possible. Now, In Architect when I tried to use the Data action it's showing me an error attached. 

    Doubts:

    Q1. Is there any way to resolve the List of Array of JSON in architect? Looks like no, still confirming from you all?

    Q2. Is the Image of showing Array of array of JSON in Data Action is right? If yes, then why the values are not showing?

    Ask for Solutions:

    Now, suggest me the best way to get the dynamic array of JSON for each user's and fetch each parameters.

    My thought to Fetch the user names and Full JSON List of all users in a JSON Collection using Data Action. Then, inside the flow using a loop I will get the index of each user and with the index I will fetch the JSON array of the Primary Contacts. After that through a loop, I need to parse each primary contact JSON objects from the list.

    Example JSON for a user:  

    {
          "id": "86cfb79b-53dc-4e2b-9fae-e7a4ce8c4458",
          "name": "Subhajit Podder",
          "division": {
            "id": "7d2f53dc-24fa-4d89-9b03-b6621efa39ef",
            "name": "Home",
            "selfUri": "/api/v2/authorization/divisions/7d2f53dc-24fa-4d89-9b03-b6621efa39ef"
          },
          "email": "subhajit.podder@Test.com",
          "primaryContactInfo": [
            {
              "address": "subhajit.podder@Test.com",
              "mediaType": "EMAIL",
              "type": "PRIMARY"
            },
            {
              "display": "(82408 66281)",
              "mediaType": "PHONE",
              "type": "PRIMARY"
            },
            {
              "display": "(82408 6111)",
              "mediaType": "SMS",
              "type": "PRIMARY"
            }
          ],
          "addresses": [
            {
              "address": "Test@gmail.com",
              "mediaType": "EMAIL",
              "type": "WORK"
            },
            {
              "display": "(82408 33381)",
              "mediaType": "SMS",
              "type": "WORK",
              "countryCode": "US"
            },
            {
              "display": "(98755 16968)",
              "mediaType": "SMS",
              "type": "WORK2",
              "countryCode": "US"
            },
            {
              "display": "(82408 6111)",
              "mediaType": "SMS",
              "type": "WORK3",
              "countryCode": "US"
            }
          ],
          "state": "active",
          "username": "subhajit.podder@Test.com",
          "version": 51,
          "preferredName": "Subhajit P",

    Document Attached:

    Data Action Export, Screenshot of UserName and Email Fetch Showing Properly in Data Action, Screenshot of Primary Contacts Not Showing Properly in Data Action, Error Screenshot in Architect to use the Data Action.


    #Architect
    #DataActions

    ------------------------------
    Subhajit Podder
    NA
    ------------------------------

    Attachment(s)



  • 2.  RE: Extract Dynamic List of a JSON Array using Data Action and Architect

    Posted 4 hours ago

    The best approach is to flatten the response in the Data Action transformation, instead of passing the full JSON array.

    You have 3 good options:

    Option 1 (Recommended): Extract only what you need
    Use translationMap and successTemplate to:

    • Filter primaryContactInfo

    • Return separate arrays like:

      • primaryEmails (Array of String)

      • primaryPhones (Array of String)

      • primarySms (Array of String)

    Architect handles Array of String perfectly.


    Option 2: Return JSON as String
    Return the entire primaryContactInfo as a single String using successTemplate:

    "${rawResult.primaryContactInfo}"

    Then parse it using string manipulation inside Architect (less clean, but possible).


    Option 3: Use Middleware
    Call an intermediate service (Node.js, Cloud Function, etc.) that:

    • Calls Genesys API

    • Processes the JSON

    • Returns only simple arrays or flat fields to Architect



    ------------------------------
    Alex Sander Felicio
    ------------------------------



  • 3.  RE: Extract Dynamic List of a JSON Array using Data Action and Architect

    Posted 3 hours ago

    Hi Alex,

    It is always better to get the result in separate list. But, I don't know whether the user has primary email or primary SMS or primary phone or all three of them or any two of them. That's the main problem. Can you please help to find the JSON Path expression for that? Because, I am thinking how to get the associated contacts from username list index in Architect while it is dynamic? 

    Suppose the index of a user is 1 and I want all the primary contacts for that. I have similar problems with another dynamic list.



    ------------------------------
    Subhajit Podder
    NA
    ------------------------------