Iterate multiple entries (Sheets rows, data store records) across nested bundles

Hello Make Folks!

I’ve been stuck on what feels like an easy problem, but no avail.

Goal
I am receiving form data via a webhook. I would like to store each form response as a row in Google Sheets. I’ve also been using the Make built in data store as another possible output. Either works for me.

Quirks of note
A) My form data has inconsistent records; sometimes one response, sometimes many.

B) The webhook data input is tricky to alter, given the limitations of how I’m generating the HTML form. (It’s a separate scenario that iterates over a text aggregator to dynamically render questions on the form. That text aggregator output sits within an email module’s HTML. All this results – as intended – in multiple questions with one submit button.)

C) I’ve tried many different things, and don’t think my current setup is my most efficient.

D) Because the forum is preventing my post for too many links, I have added spaces in all my example emails below.

Current Input

    {
        "key": null,
        "data": {
            "Note": "note1, note2, note3",
            "Admin": "example@fake. com, example@fake. com, example@fake. com",
            "Issue": "Too many mistakes, Too many mistakes, Never showed up",
            "Action": "Pat on head, Forgiveness, Called Mom",
            "Worker": "Bob One, Jane Two, Kaeli Three",
            "Date_Responded": "2024-06-10T20:33:22.369Z"
        },
        "overwrite": false
    }
]

Current Output (v1)
I can consistently create comma separated data within specific fields. This happens when I use the iterator’s array, such as {{52.array.notes}}. For example, column A might read example@fake. com,example@fake. com,example@fake. com

The full output could be described as this, across 5 columns in one row:
“example@fake. com, example@fake. com, example@fake. com”,“Bob One, Jane Two, Kaeli Three”,“Too many mistakes, Too many mistakes, Never showed up”,“Pat on head, Forgiveness, Called Mom”,“note1, note2, note3”

Alternate Output (v2)
I have also been able to create individual rows correctly, but it doesn’t iterate across the other values. This happens when I use the iterator’s specific fields, such as {{52.array.notes}}

Full output might look like this:
example@fake.com”,“Bob One”,“Too many mistakes”,“Pat on head”,“note1”

Desired Output
“example@fake. com”,“Bob One”,“Too many mistakes”,“Pat on head”,“note1”
“example@fake. com”,“Jane Two”,“Too many mistakes”,“Forgiveness”,“note2”
etc.

blueprint (4).json (13.3 KB)

Huge thanks in advance.

Welcome to the Make community!

If you have multiple bundles you need to aggregate them first before you can map out the properties/arrays that contain the data across all of the collections.

Please provide the output bundles of the trigger module by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

This will allow others to better assist you. Thanks!

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

1 Like

You got it! Thanks for jumping in.

Here’s the output of the array aggregator I have feeding into the iterator.
output1.json (1.1 KB)

And here’s the output of the array aggregator I have after the iterator. This is what feeds into the data store or google sheet.

output2.json (1009 Bytes)


Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of these four modules:

1. Remove the second array aggregator.

2. Add the “Set variable” module.

This calls the function first on the aggregated array

You should get something that looks like this

3. Iterator Iterates one of the sub-arrays

4. Map the fields in the data store

Example output

Give it a go and let us know if you have any issues!

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

2 Likes

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

View Module Export Code

JSON

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 57,
                    "module": "util:SetVariable2",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "name": "array",
                        "scope": "roundtrip",
                        "value": "{{first(46.array)}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1452,
                            "y": -3,
                            "name": "Get first array item"
                        },
                        "restore": {
                            "expect": {
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Variable name",
                                "required": true
                            },
                            {
                                "name": "scope",
                                "type": "select",
                                "label": "Variable lifetime",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "roundtrip",
                                        "execution"
                                    ]
                                }
                            },
                            {
                                "name": "value",
                                "type": "any",
                                "label": "Variable value"
                            }
                        ],
                        "interface": [
                            {
                                "name": "array",
                                "label": "array",
                                "type": "any"
                            }
                        ]
                    }
                },
                {
                    "id": 55,
                    "module": "builtin:BasicFeeder",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "array": "{{57.array.notes}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1702,
                            "y": -4
                        },
                        "restore": {
                            "expect": {
                                "array": {
                                    "mode": "edit"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "array",
                                "type": "array",
                                "label": "Array",
                                "mode": "edit",
                                "spec": []
                            }
                        ]
                    }
                },
                {
                    "id": 56,
                    "module": "util:SetVariables",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "variables": [
                            {
                                "name": "notes",
                                "value": "{{55.value}}"
                            },
                            {
                                "name": "action",
                                "value": "{{57.array.action[55.`__IMTINDEX__`]}}"
                            },
                            {
                                "name": "formCount",
                                "value": "{{57.array.FormCount[55.`__IMTINDEX__`]}}"
                            },
                            {
                                "name": "adminArray",
                                "value": "{{57.array.AdminArray[55.`__IMTINDEX__`]}}"
                            },
                            {
                                "name": "IssueArray",
                                "value": "{{57.array.IssueArray[55.`__IMTINDEX__`]}}"
                            },
                            {
                                "name": "WorkerArray",
                                "value": "{{57.array.WorkerArray[55.`__IMTINDEX__`]}}"
                            }
                        ],
                        "scope": "roundtrip"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1947,
                            "y": -4,
                            "name": "Data store"
                        },
                        "restore": {
                            "expect": {
                                "variables": {
                                    "items": [
                                        null,
                                        null,
                                        null,
                                        null,
                                        null,
                                        null
                                    ]
                                },
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "variables",
                                "type": "array",
                                "label": "Variables",
                                "spec": [
                                    {
                                        "name": "name",
                                        "label": "Variable name",
                                        "type": "text",
                                        "required": true
                                    },
                                    {
                                        "name": "value",
                                        "label": "Variable value",
                                        "type": "any"
                                    }
                                ]
                            },
                            {
                                "name": "scope",
                                "type": "select",
                                "label": "Variable lifetime",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "roundtrip",
                                        "execution"
                                    ]
                                }
                            }
                        ],
                        "interface": [
                            {
                                "name": "notes",
                                "label": "notes",
                                "type": "any"
                            },
                            {
                                "name": "action",
                                "label": "action",
                                "type": "any"
                            },
                            {
                                "name": "formCount",
                                "label": "formCount",
                                "type": "any"
                            },
                            {
                                "name": "adminArray",
                                "label": "adminArray",
                                "type": "any"
                            },
                            {
                                "name": "IssueArray",
                                "label": "IssueArray",
                                "type": "any"
                            },
                            {
                                "name": "WorkerArray",
                                "label": "WorkerArray",
                                "type": "any"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

1 Like