Mapping an array that contains a collection

Hey there, I have upgraded some of my scenarios to webflows v2 API.

The main difference i have found is when you return a list of records, all the field data is now in a collection called fieldData inside each record of the array:

I often use the map function to find the webflow ID of an item based on another field which is in the fieldData collection, eg the surburbID. However with this now being in a collection inside the array, map doesn’t work.

One work around I have found is to insert a Set Var module when I iterate through the records and then add this var into the Array aggregator. Unfortunately this means using up one token for every record, and when there are 2000 records in the webflow list, this makes it un-affordable.

The other solution I have found is people adding the webflow ID into a field in webflow, so it is returned if you map the fieldData collection. This is not ideal, as I would have to setup another automation to add the webflow ID into a field every time a new record is created.

Do you have a solution here? I would love to know!

Thanks in advance!

I found a work around.

I used the text aggregator to make some json, then used parse Json, then the aggregator.

Here is the text aggregator settings:

Parse JSON just adds the square brackets

If anyone has a better idea, I’d still love to know.

I did also discover that if you have a module after the aggregator that accepts an array, you can use that array format as a target structure for the array, and manually add fields, which should allow you to use fields from the nested collection, this may be a solution for some people.

I have no idea why map function wasn’t working before. Ignore all those work arounds, just use fieldData.Suburb to map the data in the nested collection.

2 Likes