Hi. Sometimes, I wouldn’t know which variable is going to be used in a node and need to somehow set both. In the previous versions of n8n, I would just put them next to each other like this $node["Fetch account ID by domain name"].json["data"][0].id$node["Create a company account in Salesloft"].json["data"]["id"] and n8n would take whichever one is available. After this was changed, I’ve been struggling a lot and it created so much problems for us
I’ve tried expressions like {{ $node["Fetch account ID by domain name"].runIndex === 0 ? $node["Fetch account ID by domain name"].json["data"][0]["id"] : $node["Create a company account in Salesloft"].json["data"]["id"] }}
but it would work in some cases and fail in another with an error message [No data found for item-index: "0"]
The worst part is that the flow still continues and doesn’t produce an error so I never know if it works properly or not unless manually tested.
My idea here is to check if a company already exists in Salesloft. If yes, then take the ID of it and create a note. If not, then create a company and take it’s ID and add a note. These nodes are not directly connected to the one creating note. And the structure of the variable is a bit different since one of them does a search and it’s going to be a [0] result.
What’s the best way to go about this?
- n8n version: 1.18.1