Question

Using an Array within an Array

  • 11 November 2022
  • 5 replies
  • 568 views

Userlevel 1

Hi, 

I am coming across an issue when attempting to use an array within an array objects. 

I am attempting to create objects based on an API response I receive. So the response is for example: 

1: 

name: test.com

description: this is a test

selection: 

        1: choice 1

        2: choice 2

2: 

name: test.com2

description: this is a test 2

selection: 

        1: choice 2

        2: choice 3

        3: choice 4

 

So as above I can see the choices each object has selected. BUT when I go actually use the data I just get a flat string of:

selection: “choice 1, choice 2, choice 2, choice 3, choice 4”

there seems to be no way to tell which choice originated from which object and no way to split and remarry them, I have tried many methods with no success and I can see a lot of forum posts about this that are unresolved.

It seems completely illogical for Zapier to handle arrays within objects this way. Anyone had any luck working around this?

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

Userlevel 7
Badge +14

Hi @SimonNCX 

Good question.

Try using the Formatter > Utilities > Line Item related actions.

Else, you may have to get the RAW JSON and use a Code step to handle the nested arrays.

Userlevel 1

Hi @Troy Tessalone , 

Thanks, I’ve tried every way I can think of with the line item formatters and cannot get it back to how I need it. 

How do you access the raw json? Even in code step I can only select the output data fields as input.

Userlevel 7
Badge +14

@SimonNCX 

It requires an advanced approach with 2 Zaps connected with Webhooks

 

Can you provide more details about how your Zap steps are configured currently for context?

Userlevel 1

Hi @Troy Tessalone. Right now I am using a custom app to retrieve the data above from an endpoint in an action step with a GET request, I then simply want to post these same items to the same endpoint with slightly modified data. I just cant pass the arrays back correctly because it flattens them all into one line. I can configure in any fashion necessary to achieve this. 

Userlevel 7
Badge +14

@SimonNCX 

Alternatively, you can use a Code step to make the GET API request, then handle the returned RAW JSON.