Glad that it worked. We have answered that a couple of times in the posts below. If after reading it’s still not clear, simply come back to me. I guess it makes sense to write a post about it.
@babbel1005 change {{$node[“SET TOKEN”].json[“token”]}} to {{$item(0).$node[“SET TOKEN”].json[“token”]}}.
The set token node returns 1 item, but the Fetch subentities node receives more than one item. Since Fetch subentities is going to iterate over all input items and use the item index to resolve the expressions, you end up with something as follow:
Index
Expression
Final Value
0
{{$node[“SET TOKEN”].json[“token”]}}
the token
1
{{$node[“SET TOKEN”].json[“token”]}}
undefined
2
{…
I changed {{$node["HTTP Request2"].json["body"]["external_number"].match(/\d+/g)[0]}} for {{$item(0).$node["HTTP Request2"].json["body"]["external_number"].match(/\d+/g)[0]}}.
The problem is that in the IF node, you are referencing data from nodes that have 2 different output lengths. The HTTP Request2 returns just one item, and the function1 returns more than one item.
In the first iteration it will work because both outputs have index 0, but after that, the expression {{$node["HTTP Request2"…
Assuming that the question to @harshil1712 answer is “yes” you would have to change the expression:
{{$node["Function"].json["_id"]}}
to
{{$item(0).$node["Function"].json["_id"]}}
That will then make sure to always use the id of the first item and not the id of the corresponding item (which would be for the second item, the second item of the Function node which does not exist as the Function-Node has only one item).
Hope that makes sense!
1 Like