I have an iterator which iterates over an array of objects that look like this:
[
{"field_id": "name", "value": "John"},
{"field_id": "phone", "value": "0502221321"},
{"field_id": "email_address", "value": "a@a.com"}
]
For each such object, I want to first check if it’s a relevant field_id
(let’s say only “name” and “phone” are relevant, and I don’t need “email_address”). Then for relevant objects, I want to populate a Google Sheet row so that “John” (i.e. value
field of object where "field_id"="name"
) and “0502221321” (i.e. value
field of object where "field_id"="phone"
) go into the appropriate columns (let’s say column A and B).
I’m stuck at the part between the iterator and how to conditionally select objects to go into the Google Sheets row.
If I simply choose “Add row” after the iterator - it will add a new row for each field (new row for “John”, new row for “0502221321”, etc.).
How can I select the correct value for each column in the Google Sheets?
In pseudo-code it would look like this:
for item in array:
if item["field_id"] = "name":
insert item["value"] into row A
if item["field_id"] = "phone":
insert item["value"] into row B