Genesys Cloud - Main

 View Only

Discussion Thread View
  • 1.  Creating a collections variable using a loop reading a data table

    Posted 05-12-2025 16:36

    Hi all, I struggle to generate a string collections variable based on the returned variable from a data table I retrieve with a loop after determining the table length.

    How do I build the string collection variable? I tried to use the make list, but that requires to define the amount of entries prior to the data table read and the data table length does vary. so basically when the list is 4 entries I expect "variableName, item 1, item 2, item 3, item 4" and when it is just one entry i expect "variableName, item 1"

    I've been breaking my head on this for the past few days any suggestions appriciated.


    #ArchitectureandDesign
    #Unsure/Other

    ------------------------------
    Ruud Reinold
    BNP Paribas Personal Finance UK
    ------------------------------


  • 2.  RE: Creating a collections variable using a loop reading a data table
    Best Answer

    Posted 05-12-2025 17:34

    When I did this in a Script - I think you are working in Architect - I had to create a Data Action to use the Genesys Cloud API to get all the rows in a table. In the script, you can run the data action on load and assign the arrays that are an output of the Data Action to a list of strings variable. So, if you have two columns (e.g., Key, Value), you can create two list of strings variables to hold the Key values and the Value values.

    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"
              },
              "Valuel": {
                "type": "string"
              }
            }
          }
        }
      }
    }

    Admittedly, it has been a while since I built this, but please provide some additional details. Are you working in Architect or in Scripts?



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



  • 3.  RE: Creating a collections variable using a loop reading a data table

    Posted 05-12-2025 20:12

    Can you share what you have already in Architect / Script

    Certainly in Architect you don't need to declare the list size and can always add another item to the collection and it will adaptively increase in size. Collections are more like a list than an array from languages like C#.



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



  • 4.  RE: Creating a collections variable using a loop reading a data table

    Posted 05-13-2025 06:31
    Edited by Rudy Reinold 05-13-2025 09:32

    I found the answer in one of the YouTube video's 

    by using the Split Function, what Identifies sub-strings in the supplied text separated by a delimiter.

    ------------------------------
    Ruud Reinold
    BNP Paribas Personal Finance UK
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources