Best answer

Trouble with Google Sheets values not updating correctly during a loop in a Shopify to Firestore Zap

  • 11 March 2024
  • 7 replies
  • 26 views

Userlevel 1

Below is a screenshot of my process.

The JavaScript code goes through each Shopify order line item & calculates a sum of the total number of items orders. (Output = {Sum})

I then loop through the rest of the process from 1 to Sum (num of items)

In this loop:

  1. I query a Google Sheet to get all values in column A
  2. Retrieve the last value in the column
  3. Delete that value from the sheet
  4. Create a Firestore document with the following fields:
    1. Buyer Name
    2. Buyer Email
    3. Buyer Address
    4. The retrieved value from the Google Sheet

This is the problem in a case study:

  1. The new order has a total quantity of 4 items
  2. 4 Documents are created in Firestore/Firebase
  3. The first document has the correct retrieved value from the Google Sheet
  4. Documents 2-4 all have the same retrieved value from the Google Sheet.  Different from the first, but the same from 2-4.
    1. It is as the Google sheet actions are only triggered one time.  The rest of the loop iterations just use the same retrieved value as document 2.

 

icon

Best answer by Troy Tessalone 12 March 2024, 04:26

View original

7 replies

Userlevel 7
Badge +14

Hi @OneBear 

For us to have full context, we will need to see screenshots with how the steps are configured.

Userlevel 1

Okay!  Here are the screenshots in order:

 

 

Userlevel 7
Badge +14

@OneBear 

Loop iterations run in parallel.

Within the loop add a Delay step. (Delay For or Delay After Queue)

 

Userlevel 1

Okay I will add a 1 minute delay.  Where should the delay be placed?  Right before the firestore document creation action?

Userlevel 7
Badge +14

@OneBear 

It should be the first step within the Loop.

Userlevel 1

You’re the man.

Thanks a ton.

Userlevel 7
Badge +6

That’s awesome @OneBear! A huge thanks to Troy for lending a hand here!

If you have any other questions, please don’t hesitate to reach out to the Community. We’re always happy to help! 🤗

Reply