Adding multiple files/PDFs/images without overwriting in Notion "Update Database Item" function

A single “file” field on a Notion database supports multiple files, whether they be images, PDFs, or other files. However, the Notion “Update Database Item” function defaults to overwriting a single existing file rather than appending a new file.

The following is my output from my iterator that is then going to the Notion “Update Database Item” function:

[
    {
        "value": "https://myurl.com/1.webp",
        "__IMTINDEX__": 1,
        "__IMTLENGTH__": 3
    },
    {
        "value": "https://myurl.com/2.webp",
        "__IMTINDEX__": 2,
        "__IMTLENGTH__": 3
    },
    {
        "value": "https://myurl.com/3.webp",
        "__IMTINDEX__": 3,
        "__IMTLENGTH__": 3
    }
]

This works properly, except I only end up with 3.webp in my Notion database. I can see that 1.webp gets uploaded first, then replaced with 2.webp, then replaced with 3.webp. Instead, I’d like for all of these images to get uploaded. I can’t just enumerate them all in the Notion function because the number of images in each upload is not constant. There could be anywhere from 1 to 10 depending on the preceding steps.

This is the Notion configuration:

This is the workflow configuration for the branch in question:

It seems like I could select “map” and put something in here, but I’m not sure what to put …

Is there any way to resolve this?

Welcome to the Make community!

You’ll need to fetch the existing record and merge the existing array with the incoming array.

Every result (item/record) from a iterator module will output a bundle. To “combine” them into a single structure, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module.

Read this

The Array Aggregator module also allows you to build a complex array of collections for a later module’s field to map multiple items (collections) to it.

Here is an example of using the “Target structure type” of an Array Aggregator module:

As you can see, the “Map” toggle on fields are used when you have an array. You can easily build an array variable to map to a field, by using an Array Aggregator module and select the “Target Structure Type” as the future field you want to map the array into.

samliewrequest private consultation

Join the unofficial Make Discord server to chat with us!

2 Likes

Thank you! That worked perfectly.

2 Likes