Word template with loop not working with array aggregator

Hi. New user here, and I’ve hit a complete dead-end trying to populate a Word template.

I’m trying to download a record from Airtable, iterate over some one-to-many child records (in my test data there are 2), then populate a Word document using both the original record, and the child records in a loop.

The actual result I’m seeing is that only a single child record appears in the Word document.

Here’s the input and output of the array aggregator:

[
    {
        "id": "recxcFlePIxxsfUr8",
        "Name": "Joe Bloggs"
    },
    {
        "id": "recNjTlClX9LzgNK9",
        "Name": "John Smith"
    }
]
[
    {
        "array": [
            {
                "id": "recxcFlePIxxsfUr8",
                "Name": "Joe Bloggs"
            },
            {
                "id": "recNjTlClX9LzgNK9",
                "Name": "John Smith"
            }
        ],
        "__IMTAGGLENGTH__": 2
    }
]

But then the input to the Word template module only shows 1 item from the array:

[
    {
        "data": "xxx",
        "values": [
            {
                "key": "CompanyName",
                "value": "ABC Trading Ltd",
                "valueType": "value"
            },
            {
                "key": "RegNumber",
                "value": "12345678",
                "valueType": "value"
            },
            {
                "key": "Directors",
                "value": [
                    {
                        "entry": [
                            {
                                "key": "Name",
                                "value": "Joe Bloggs"
                            }
                        ]
                    }
                ],
                "valueType": "loop-section"
            }
        ],
        "fileName": "ABC Trading Ltd.docx"
    }
]

If I remove the array aggregator, I get two Word docs, each containing one of the child records.

Can anyone see where I’m going wrong please?

Some screenshots of the Word template config:

This is the contents of my Word template:

Documents for {{CompanyName}}. Company registration number {{RegNumber}}.

The Directors are:

{{#Directors}}
{{Name}}
{{/Directors}}

And this is what I get in the Word document:

Documents for ABC Trading Ltd. Company registration number 12345678.

The Directors are:

Joe Bloggs

Is there anything else that I could add to my post, to try and solve this?

Finally got this working.

It turns out that I didn’t need the array aggregator. (I don’t understand why it didn’t work when I removed it before, but something else must have been wrong).

1 Like