Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  How to map nested data within API call

    Posted 10-20-2025 06:38
      |   view attached

    Hi

    We are currently in the early stages of setting up an integration with our CRM.

    Our CRM is customer based, so one customer can have multiple subscriptions.

    We're succesfully able to pull back customer data and present this in a script to our agents however I want to start pulling thorugh data relating to their subscriptions.

    When I test our data action I can see we're pulling the data through but its mapping to nested fields (apologies if my terminology is off, this all new to me 😂).

    As you can see in the attachment we have the field 'subsSubRef' in our data action which is available in my 'Call Data Action' block in Architect. When a customer has multiple subscriptions the sub ref maps to 'subs.SubRef-0' and 'subs.SubRef-1'.

    I need to work out how I can reference the data in 'subs.SubRef-0' and 'subs.SubRef-1' within my script and present it to agents.

    Any advice would be greatly appreciated.

    Thanks,

    Josh 


    #DataActions

    ------------------------------
    Joshua Quelch
    Technical Support Executive at Air Business Limited
    ------------------------------


  • 2.  RE: How to map nested data within API call

    Posted 10-20-2025 07:46

    Hi Josh

    In Architect, nested fields like subs.SubRef are treated as collections. How you handle them depends on your business logic and flow design, usually, it's best to process or format the data in the flow and send only what agents need to the script.



    ------------------------------
    Luiz Rosa
    Full stack developer
    ------------------------------



  • 3.  RE: How to map nested data within API call

    Posted 10-20-2025 10:08

    Hi Luiz

    Thanks for your response, this is all new to me so apologies for stupid questions. 

    How would I go about splitting the collection down into separate variables that I can then reference in the script?

    I want to be able to reference subs.SubRef-0 and subs.SubsRef-1 within my script.

    I was reading about using the Update Data block to create a collection but I'm not sure I'm doing it right.

    Thansk,

    Josh 



    ------------------------------
    Joshua Quelch
    Technical Support Executive at Air Business Limited
    ------------------------------



  • 4.  RE: How to map nested data within API call

    Posted 10-20-2025 10:29

    Hi Joshua,

    subs.SubRef (this will be the name of your Output) will be referenced at your flow as a collections, you can set this return to some variable as Task.SubRef or other name you want, and use GetAt(Task.SubRef, 0) to get the firt position in your collection. Collections works like an Array inside architect, including starting the first position as 0.

    Also, you can check the lenght of this collections with Count(Task.SubRef) and use in a loop block for exemple.



    ------------------------------
    Debora Lopes
    ------------------------------



  • 5.  RE: How to map nested data within API call

    Posted 10-20-2025 11:18
      |   view attached

    Hey Debora,

    Thanks for your input, I just want to test my understanding as its possible I'm getting this completely wrong 😂.

    I've created a loop to count the number of variables within the collection:

    Count(Flow.SubRef)

    I've then used update data to create 3 new variables (Flow.SubRef0, Flow.SubRef1, Flow.SubRef2) and matched those to a GetAt(Flow.SubRef,0/1/2)

    Flow.SubRef0 = GetAt(Flow.SubRef,0)

    Flow.SubRef1 = GetAt(Flow.SubRef,1)

    Flow.SubRef2 = GetAt(Flow.SubRef,2)

    May not be the clearest explanation so I've attached a screenshot too.

    Again, I may have completely mossed the mark with this, but that seemed somewhat logitcal to me.



    ------------------------------
    Joshua Quelch
    Technical Support Executive at Air Business Limited
    ------------------------------



  • 6.  RE: How to map nested data within API call

    Posted 10-20-2025 11:05
    Edited by Luiz Rosa 10-20-2025 11:06

    Hi Joshua Quelch, no worries, we're here to help.

    You can loop through the items and use GetAt() to extract each value dynamically.

    If you prefer to expose fixed paths like subRef[0] or subRef[1] in your Data Action, keep in mind that this can fail if the collection has fewer elements than expected. For variable responses, looping through the collection is the safer approach.

    Also, when splitting or iterating through a list, it's important to understand the business logic behind it. You need to define what criteria you'll use to separate or process each item, since that drives how the data should flow and what the script should expect.

    Here's an example of looping through a collection in Architect:

    Hope this helps.



    ------------------------------
    Luiz Rosa
    Full stack developer
    ------------------------------



  • 7.  RE: How to map nested data within API call

    Posted 10-20-2025 11:19

    Ahh I hadn't seen this, I'll take a proper look through now and see if I can implement.

    Thank you!



    ------------------------------
    Joshua Quelch
    Technical Support Executive at Air Business Limited
    ------------------------------