Convert Workflows json to two different data sets

Hi there,

Can anybody please help me to convert the workflows json to two different data sets, being:

  1. workflow ids and names
  2. all nodes data together with the workflow id for each node

I’m basically trying to create a structure where I can search the nodes to see in which workflows they’re being used.

Here’s an example of the workflows json:

Thanks in advance.

P.s.: it really took me some time to get my head around the function nodes, but the (new) Code node behaves differently all together, and I’m really struggling with it. Currently, I’m getting more errors than results. For example, when creating the workflows sample data, I had to remove text from the data …

took me a while, but I finally got it :wink:

let items = $input.all()[0].json.data

//return items

let results = [];

let test = items.length

let i = 0;

for (item of items) {
  for (node of item.nodes){
    i++; // test
    results.push({
      json: {
        // number : i,
        node: node.name,
        type: node.type,
        workflow: item.name,   
        nodeId: node.id,
        workflowId: item.id  
      }
    })
}
}
return results
2 Likes

Amazing, thanks for sharing!

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