Array Iterator and Google Sheets

Hello,
My Goal is insert new row on Google Sheets after receiving a webhook with last sale info.

The problem is that on the webhook depending on the sale. It can have 1 or 2 items.

On the scenario where only has one item it is working properly.

What i need help is on population google sheets on the scenario where 2 itens are sent on the webhook.

Here is an example of the webhook array:

“items”: [
{
“code”: “67166”,
“name”: “Product 1”,
“description”: “description 1”,
“sales_plan_code”: “72355”,
“sales_plan_name”: “Plano base”,
“image”: “secure.site.com/image/product/77087154/60715/1684172012641_291342/png”,
“type”: “PRODUCT”,
“amount”: 1,
“item_value”: 67,
“sale_value”: 67
},
{
“code”: “65401”,
“name”: “Product 2”,
“description”: “description 2”,
“sales_plan_code”: “42948”,
“sales_plan_name”: “Plano base”,
“image”: “secure.site.com/image/product/77087154/55032/1677449618006_900236/png”,
“type”: “ORDERBUMP”,
“amount”: 1,
“item_value”: 9.9,
“sale_value”: 9.9
}
],

In this case what i need to do is:

Populate the Google Sheets with item 1 information (type=product) and populate some specifics columns about product 2 (type=orderbump).

Columns that I need to populate:
Orderbump - need to put Yes or No. If webhook send the array with 2 items populate with yes
Orderbump Product Name - insert the item 2 name
Orderbump Sale Value - insert the item 2 sale value

I don’t know how to accomplish that. Here is the scenario print screen.
One possible option could check if “type” is product go ahead and populate on sheets about the main product, if “type” is orderbump populate the orderbump info on sheets.
Any help is appreciated.

Hello :blob_wave:

In case you need to work with multiple array items within one Google Sheet row, you can’t use the “Iterator” module as you need to have all items in a single data bundle.
The “Iterator” does the opposite - it iterates multiple items from a single bundle (array) into multiple bundles.

You will then need to incorporate either “get” and “map” combo or “mapping an array’s nth element” technique to extract the specific items from the array.

I hope it helps.

Cheerio :cat_roomba:

2 Likes