Best answer

Looping through array to find specific value

  • 6 February 2023
  • 5 replies

I am working on a workflow to get data about a ticket from one of our internal systems. That ticket may have one or more relations(links) to other entities attached to it. 

I start by GETting the data via API, however Zapier insists on parsing it for me instead of providing raw JSON. Since the number of links can vary, I need to be able to iterate through n number of entries to find a match. 

I kinda reconstructed the relevant data using Formatter so now I have an example with two entries

I want to loop through these items and search the “url” key for a match from my input data and if a match is found, extract the “id” value, which I will need to make a separate API call later. I can’t for the life of me figure out a way to do this that yields the ID I need for the next step. 


I’m afraid it’s heading down to custom code and that’s pretty far beyond my skillset right now. Anyone out there spot an approach I might be missing?



Best answer by Troy Tessalone 6 February 2023, 23:47

View original

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 @Dan R 

Good question.

Have you tried using the Looping app to handle 1+ line items?

Hey @Troy Tessalone 

Thanks for engaging so quickly! Yes, I am using a loop with a filter step immediately after to test for a match on the “url” attribute.  I figure that’s the most logical way to handle a variable number of items that I will need to sort through.

Here’s what my setup looks like.

The loop (takes Line Items from formatter step)

The Filter (checks that there’s an ID and that the ticket matches)

Trying to  continue to the next step where I take the ID and use it as a resource ID for my next API call (no ID available)

Is there something I’m missing or any way you can think of to get that ID that passed the filter as an actionable item for a later flow?


Userlevel 7
Badge +14

@Dan R

Every Loop iteration will output the same defined parameters. (e.g. id, url)

So if you are trying to use the ID from the Looping step, you can simply map the “id” parameter from step 7.

When testing the Looping step, only the 1st iteration output will be available to map.

So you’d have to turn the Zap ON to test all the iterations.

Then check your Zap Runs:

Thanks Troy - So to be sure I understand, when I make step 9 after my filter step, just map the ID value from Step 7 (even if the first value shown is incorrect?) because that’s just how Loops work? 

I’ll give it a try this evening, appreciate the help!

Userlevel 7
Badge +14

@Dan R 


For example, if you map the ID from Step 7 (Looping), then on the 1st iteration it will have a value of 8984887, and on the 2nd iteration it will have a value of 8984765.