Need vaules from previous node within Split Out node flow

Hello,

I have version 1.33.1 (self Hosted)

within my workflow I had to add the Split Out node but after that I can’t access the Values from e.g. “PD- Get all Deals node” within the “PD - Update Product duration/frequency”
The “PD - Get all Deals” node has only one Item as output the Split Out can have more.

two questions:

  1. how can I access all the Data from the nodes before “Split Out” node?
  2. how can I aggregate all from “Split Out” node to “Aggregate” node so I have only one output after aggregate?

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hello @Sebastian1

To reference something before the split out node, you can use that syntax:
`{{ $(‘nodename’).last().json.fieldname }}

To aggregate the data, you will need to normalize all 3 inputs so that they return the data with the same field names. Or you can use the aggregate node for each of the inputs

Thank you Barn4k,

The last() seemed to work. But it seems now difficult to access the split out data somehow

For the aggegate how can I tell the aggregate node that it should aggreate the items from the split out node?

grafik

Sorry coming from make and try to get into the new way :slight_smile:

There is a couple of things going on here. You are splitting the items into batches(of 1) and also you have multiple paths coming together.
If you want to combine paths you need the merge node. As a node will execute for each input. And I see 2 incoming green lines on one of your screenshots. So the aggregate will not work as that only works within 1 execution of the node.
So you need to add the merge (append mode) to make sure all data is combined into one item set/list and then you can aggregate them into a single item if needed.

Most often it is good to use a subflow when you are doing more complicated flows within a loop. This might be a good idea here as well.

1 Like

Hey thank you again for your help. The subworkflow sounds like a good solution and should do whats needed. But somehow I do not get any data in the subworkflow? I thought I put this module

and everything which happen so far in the previous nodes should be passed to this node?

but it seems not since I get that error message

How can i pass the data to the subworkflow?

OK I got it. In the node after “Execture Workflow Trigger” I have to use the data like $json…

But It seems this node does only get the data from the previous node and not from all the other nodes. I could I pass the data from the trigger node into the subworkflow?

you could merge in the data from the trigger node before the “execute wf” node.
Or you add the data using the code node.
(the sample code in the code node gets you half there)

edit: the easiest path should be to add an edit node

To make it more clear. I use dynamic credentials where the API token comes from the trigger node. so each HTTP node uses the same credentials but how can I specify this within the sub workflow? I could create another dynamic credential account to do this but Ideal would be to use the same ones.

So far I did use this expression but adding a third solution would be not ideal also don’t know if it would work

{{ $(‘JotForm Trigger’).item.json[“Hinterlegen Sie hier Ihr API-Token”] || $(‘JotForm Trigger’).last().json[“Hinterlegen Sie hier Ihr API-Token”] }}

This I still do not understand. I have this expression

{{ $(‘JotForm Trigger’).item.json[“Hinterlegen Sie hier Ihr API-Token”] || $(‘Execute Workflow Trigger’).item.json[‘Hinterlegen Sie hier Ihr API-Token’] }}

And get this Error in the sub-workflow “JotForm Trigger” node doesn’t exist [Error resolving credentials]

This somehow make sense because it does not exist in the subworkflow but I thought I would then use the second option or do I need some other expression for that?

fixed it this this

{{ $exists(‘JotForm Trigger’) ? $(‘JotForm Trigger’).item.json[“Hinterlegen Sie hier Ihr API-Token”] : $(‘Execute Workflow Trigger’).item.json[‘Hinterlegen Sie hier Ihr API-Token’] }}

seems still not to work. I did create another dynamic credentials for the subworkflow

the Edit Fields node is intended to run before the execute Workflow node. Thereby appending the data (token) to each item before sending it to the child workflow.

The child workflow should only have the data, not a refference to the previous wf.

3 Likes

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