Data format, mapping, processing an array

Hi Makers, I’m uncertain how to handle this data format, could you advise?

I’m hoping to loop through each record of “Travel Mates” provided by a form.

Here’s the scenario:

And input I’m receiving:
image

I’m uncertain how to process the array in the iterator to get to the desired record.
image

As currently it doesn’t provide the individual records, but only the total number of bunders and position of the respective bundle.

Thanks for your advise!

PS: I’m uncertain what to call this actually and happy to adapt the title according to your suggestions. :slight_smile:

You should not select a value within the array to iterate – you should select the ARRAY itself for the Iterator’s “Array” field.

From your last screenshot, it looks like the Travel Mates variable is not an array for some reason, hence the output is not what we would expect.

2 Likes

Thanks @samliew, is it possible to use inline functions or a variable module to transform format the variable comes in to the array format required for the iterator to work?

In other cases, it was indeed just as easy as to enter the array into the iterator for it to work out of the box. The data format in this case appears to prevent this.

Welcome to the Make community!

1. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

2. And most importantly, Output bundles

Please provide the output bundles of the trigger module (Module with the [2] in the square box) by running the scenario, then click the white speech bubble on the top-right of each module and select “Download output bundles”.
Screenshot_2023-10-06_141025

A.

Save the bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading it here will look like this:

bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted output bundle in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

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

Following these steps will allow others to assist you here. Thanks!

2 Likes

Thanks @samliew, I’m unable to upload the text file, but have copied the output below and attached the blueprint.

blueprint.json (886.7 KB)

[
    {
        "submissionId": "XXX",
        "formId": "XXX",
        "fornName": "XXX,
        "submissionTime": "XXX",
        "answers": {
            "8NmRXNCGE8H2ik8UjdKC3G": "",
            "aV56KpDUHZLhhRTvinL7sN": "XXX",
            "h2Ws4Cexsj1wHPSKSNZ5Ui": [
                {
                    "Company": "XXX",
                    "Invoice": "XXX",
                    "OpsName": "XXX",
                    "URL": "XXX",
                    "PartnerID": "XXX",
                    "P-Self-Guided#": 3,
                    "P-BuyIn#": 0,
                    "LogoURL": "XXX",
                    "recordID": "XXX"
                }
            ],
            "im2eb9HyvQrEbVEvxPwwHB": [
                {
                    "cNotes": "XXX",
                    "Phone": "XXX",
                    "Country": "XXX",
                    "Travel mates": [
                        "recTqNpkuSA9jdKFd"
                    ],
                    "NameFirst": "XXX",
                    "NameLast": "XXX",
                    "DBL": 1,
                    "Gender": "XXX",
                    "SourceAdded": "XXX",
                    "Form": "XXX",
                    "Guest": "XXX",
                    "Pax": 2,
                    "GuestID": "XXX",
                    "Link:Fillout:Update": "XXX",
                    "Link:Jotform:Meeting": "XXX",
                    "Link:Jotform:Feedback": XXX",
                    "Tour-Room": "-",
                    "PaxChecker": XXX,
                    "Created": "XXX",
                    "TypeRoom": "XXX",
                    "Trigger": "Add",
                    "LastmodifiedPhone/Email": XXX",
                    "Last Modified": "XXX,
                    "Check": "Tour",
                    "Tour String": {
                        "error": "#ERROR!"
                    },
                }
            ],
            "kje3omT37u3SCkCKSHHAvh": [],
            "qm7iJvL2nFt2MGswGZdhTo": "XXX",
            "rHeBbcxkxYzteNgpGmsV5s": "XXXX",
            "v5mrjKYbEJVfmJtjL7yKYp": [
                {
                    "Title": "XXX",
                    "Days": 8,
                    "Product": "XXX",
                    "recordID": "XXX"
                }
            ]
        },
        "urlParams": {
            "c": "XXX"
        },
        "calculations": {}
    }
]

There are three arrays, so this is one way to do it, much like the movie Inception:

1. First array, convert answers collection to array

Screenshot_2024-01-25_200037
e

2. Second array, iterate values

Screenshot_2024-01-25_200045

3. Add filter to only return “`Travel mates`”

4. Iterate Travel mates array

Screenshot_2024-01-25_200109

Output

Screenshot_2024-01-25_200128

2 Likes

Hehe, that’s indeed an Inception or at least a matrushka doll.

Thanks for the instructions! I followed those, but am unable to select a variable from the second iterator (module 20/33) in the following step. It only provides a generic “Value”.

Here’s the output bundle of the second iterator:

[
    {
        "Travel mates": [
            "recNHaheeHr36rixW",
            "rec2FIczQsaqAIBDT"
        ],
        "Type": "Lead",
        "NameFirst": "TESTF1",
        "NameLast": "TESTL1",
        "DBL": 1,
        "SourceAdded": "Fillout:B2B",
        "Form": "https://build.fillout.com/editor/oSBtPiBGRcus/edit/bF8KJ7Y8CQ",
        "Guest": "TESTF1 TESTL1",
        "Pax": 2,
        "GuestID": "rec0YIjw54f2jJIUg",
        "Link:Fillout:Update": "https://form.zbulo.org/t/cbTFjzgXb5us?id=rec0YIjw54f2jJIUg",
        "Link:Jotform:Meeting": "https://form.jotform.com/Zbulo/meeting?departure=&guest=TESTF1%20TESTL1&meeting=&host=&phone=&greeting=TESTF1",
        "Link:Jotform:Feedback": "https://form.jotform.com/Zbulo/feedback?departure=&guest=TESTF1%20TESTL1&name[first]=TESTF1&name[last]=TESTL1&email=&group=&guestid=rec0YIjw54f2jJIUg&guide1=&guide2a=&guide2b=&style=",
        "GuestRowHTML": "<li><a href=https://form.zbulo.org/t/cbTFjzgXb5us?id=rec0YIjw54f2jJIUg>TESTF1 TESTL1</a></li>",
        "Tour-Room": "-",
        "PaxChecker": 2,
        "Jotform": "www.jotform.com/edit/",
        "RETIRED Link:Jotform:Join": "https://form.jotform.com/Zbulo/your-details?departureid=&booking=&group=",
        "Created": "2024-01-25T10:35:36.000Z",
        "TypeRoom": "DBL",
        "Last Modified": "2024-01-25T10:35:36.000Z",
        "Check": "Tour",
        "🤖 Weekly": "Departure",
        "GuestRooming": "TESTF1 TESTL1",
        "LastModifiedEmailDeparture": "2024-01-25T10:35:36.000Z",
        "Tour String": {
            "error": "#ERROR!"
        },
        "RETIRED Link:Jotform:YourDetails v2": "https://hook.eu1.make.com/i8j3yabe7n0s6npdoocs5210akffhhft?type=details&guest=rec0YIjw54f2jJIUg",
        "WhatsApp": null,
        "RETIRED Link:Fillout:Create": "https://app.fillout.com/t/cbTFjzgXb5us?tour=&b=",
        "RETIRED Link:Jotform:YourDetails": "https://form.jotform.com/Zbulo/your-details?guestid=rec0YIjw54f2jJIUg&departureid=&booking=&group=&fname=TESTF1&lname=TESTL1&email=&phone=&remarks=&meeting-point=&arrival=&departure=&flights=&id=&issued=&emergency-name=&emergency-phone=&emergency-email=&birthplace=&citizenship=",
        "PassportResize": "https://hook.eu1.make.com/19mtv5mvdse0ybeuicqcxmcvnrr8k72t?id=rec0YIjw54f2jJIUg",
        "Calculation": 0,
        "Calculation 2": 0,
        "Gender?": "https://hook.eu1.make.com/37q4luw4a7sy7q83ts54utmgtetudm8h?id=rec0YIjw54f2jJIUg&name=TESTF1",
        "Calculation 3": "Yes",
        "recordID": "rec0YIjw54f2jJIUg",
        "__IMTINDEX__": 1,
        "__IMTLENGTH__": 1
    }
]

It appears that the output/array in your setup is differently structured to be recognized.

I have to test whether the bundle position is static, but could an alternative approach work where I filter the output of the the first iterator (with the “to array”-function) for a static bundle position and try to map the given key Travel mate? On a first attempt of mine, that failed with error:

Failed to map 'array': Function 'map' finished with error! '' is not a valid array.

Hi @Zbulo

You can run the iterator module once to see the values in next module to map.

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

2 Likes

Type in exactly this (case-sensitive), or copy-paste in the last Iterator:

{{20.`Travel mates`}}

2 Likes

@samliew thanks again, I updated thie , but for some reason the bundles get mixed up.

Bundle 7 includes {{20.Travel mates}}:

But Bundle 6 instead of 7 passes the filter:

And ending in an empty input for module 21.

Any idea why the bundles get mixed up in the filter?

Looks like the output of the second iterator is an array with only one item.

So you need to get the first item of the array before we can access Travel mates.

{{ 20.array.1.`Travel mates` }}

3 Likes

Thanks for your enduring support. The marked solution including the following posts helped to crack this nut. I didn’t know how to unpack nested arrays and that one can use variables that aren’t shown in the scenario builder, learned something know. :slight_smile:

3 Likes

No problem, it’s my pleasure to be able to help!

2 Likes