I have multiple code nodes going into a single slack node. i want to use the output of those code nodes to create a slack message. The issue is that in the message, I’m trying to refer to the different code nodes, but they end up not returning.
and the code node names are user_code and contract_code
in the slack node, if iI select the user_code as the input, I can do {{ $json.Users }}, but then (as expected) if I switch to contract_code I’m not getting users, I’m getting contracts.
I thought I could do something like {{ $('contracts_code').item.json.Contracts }} and {{ $('users_code').item.json.Users }}, but those are invalid.
If I do {{ $('users_code') }} even when I have it selected it previews as [Object: {}] which is odd since there are values in the left hand side of the node when I’m building.
These expressions look good to me in principle. Is there a chance these aren’t executed sequentially (so only one of the two Code nodes actually has data whenever your Slack node runs)? If so, you might need a Merge node to bring these two together before your Slack node. For example like so:
This way, you can simply reference the Merge node instead of your individual code nodes which should be easier.
So, I think it ended up being something more like {{ $('Users3').all()[0].json.total_users_now}}
The trial and error methodology of this (i.e., knowing I needed to reference an array) and then all the n8n specific terms like all and json isn’t ideal. A great feature would be the same drag and drop from the previous nodes into the query builder versus having to write these references by hand.