Mapping An Array To A Field

I’m creating a PandaDoc document via their API. Their Postman collection includes an example of the content that needs to be included in the API request but I’m using Make’s in-built module for this.

I need to populate the rows in a pricing table based on the contents of pages from Notion. So I want to create the rows using an Aggregate To JSON step -

and then I’m mapping the JSON like -

The output of the Aggregate To JSON step is an array of objects. Except apparently it isn’t because when I made the request, I get an error -

BundleValidationError

Validation failed for 1 parameter(s).

  • Array of objects expected in parameter ‘rows’.

I’ve tried parsing the JSON string into an object with {“rows”: JSON string} but when I map that, PandaDoc thinks that the required fields are missing, presumably because I’ve added a rows object to the rows field that’s already included in the form.

If I have an array of objects in a JSON string, how can I map that to the field in form so that it’s recognised correctly?

Sample JSON from the aggregate to JSON step -

[
    {
        "data": {
            "QTY": 1,
            "Tax": {
                "type": null,
                "value": null
            },
            "Name": "Airplane Ticket",
            "Price": 300,
            "Description": null
        },
        "options": {
            "optional": false,
            "qty_editable": false,
            "optional_selected": false
        }
    },
    {
        "data": {
            "QTY": 2,
            "Tax": {
                "type": null,
                "value": null
            },
            "Name": "Designer 2 Days",
            "Price": 600,
            "Description": null
        },
        "options": {
            "optional": false,
            "qty_editable": false,
            "optional_selected": false
        }
    }
]

Note: I’m not including a blueprint here because setting up the automation without the Notion databases &/or a PandaDoc account wouldn’t work.

You should have used an array aggregator instead, because the field is expecting an ARRAY.

You use a JSON aggregator only if it expects a STRING.

Every result (item/record) from a search/match 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.

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.

3 Likes

Got it, thanks for the pointers!

This works really well -

2 Likes