Combine multiple items of same array by specific key

Hello,

I’m trying to write a workflow that gets specific messages from gmail, appends them to a google sheet, gives them a tag (so it doesn’t append the same messages the next time the workflow gets executed).

The workflow also renames and uploads all attachments to a specific folder inside google drive. Now I want to add the attachment links to the specific emails inside the google sheet.

This works fine, if the email only has one attachment but the system breaks if it has multiple attachments.

That’s why I’m asking if there’s any way to combine items (in this case the attachment) if they have the same value (in this case the ‘emailid’). Ideally the custom function would output something like “link1, link 2, link 3” if there are multiple attachments.

Thank you for taking your time and reading this :slight_smile:

1 Like

Replying to myself because I found a working solution:

It is actually possible with a script found here: How to join elements in array by Merge key / Combine arrays by key by Function item - #3 by Benjamin123

1 Like

Perfect that is good to see, This was on my list to look at for you but it looks like you found the answer :raised_hands:

1 Like