Merging 2 or more arrays

@MutedJam

works … mostly. I modified your Code node to somehow fit my use case (names etc):

I have this

const tickets = $('Fetch ticket').all();
const articles = $('Fetch articles').all();

for (const ticket of tickets) {
  ticket.json.articles = articles
    .filter(article => article.json.ticket_id === ticket.json.id)
    .map(article => article.json)
}

return tickets;

but this returns the articles “inside” of the ticket.

My alternative solution formats it differently (and works with my converter):

const ticket = $('Fetch ticket').first().json;
let articles = $('Fetch articles').all()

  articles = articles.map((article) => article.json)

return {
  json: {
    Ticket: ticket,
    articles
  }
}

Do you think my way is OK as well? Any recommendations? thanks

1 Like

Looking good to me, assuming your workflow only processes one ticket at a time :slight_smile:

Currently the plan is to trigger this via webhook: each time a ticket is closed → trigger workflow.
So, yes: only one ticket per time.

Sure, might be done differently in the future.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.