Skip to main content
Best answer

How do I store value in the same order with a loop launching at the same time?

  • 2 January 2024
  • 2 replies
  • 63 views

Hi guys,

 

I’m looking for a solution using a loop while looking for specific value and storing those value in an items list and keeping the order.

 

My zap goal is to so send new order in Shopify to a billing software called Evoliz. 
 

So here are my zap steps

  1. Catch a new order from shopify
  2. Check if the customer exist in evoliz, if it doesn't it create it.
  3. I'm counting the number of products in my order. 
  4. I'm starting my loop for each product present in my order
  5. For each product from the shopify order, I'm checking if this product exists in evoliz, if not I create it. For each product I will get an ID.
  6. This is where I'm stuck, I need to create a list (an array) of the different  ID I  get from step 5
  7. I use a filter to "stop" my loop once I reached the last product of the order.
  8. In this last step I create my invoice. This were I will use the item list I created earlier.
     

I need to send the ID of the products in an items list so something like that ID1,ID2,ID3 …. I manage to do that using Formatter, line Itemizer.

My problem is how the loop works.

When I launch my zap, zappier will start the first iteration of the loop. Then it will start all the other iteration of the loop in parallel.

In step 5 I’m looking for the article in Evoliz, if it’s not already in Evoliz Zap will create the article in Evoliz, and the will be longer than just looking up for the article.

So If I have 3 products in my order from shopify let’s say Product1, Product 2 and Product3.
Product 1 and 3 already exists in Evoliz but not Product 2. 

If I launch my zap, step 5 for Product 2 will be longer than the same step from Product 3.

And in the end my line of item will look like this:

ID Product1, ID Product 3, ID Product 2

while I need to get:

ID Product1, ID Product 2, ID Product 3.

I thought about introducing a delay to prevent that but I’m note convinced this is the best solution since I don’t know how many product will be in my order.

 

Any idea how to deal with that?

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

2 replies

Userlevel 7
Badge +14

Hi @Rigawel 

Good question.

You will need to add a Delay For within the Loop to space out each iteration, so they don’t run in parallel.

 

Check out this for guidance:

 

Thanks I that’s what I was thinking.

To be sure I added a calculus step before the delay to increase the delay for each iteration.

 

Best regards.