Item Linking with Code Node

Describe the problem/error/question

I have a part of a workflow that takes in many messages from Teams, and grabs their created time, converts to epoch time and then runs through a code node to filter based on that timestamp to get as close to another time stamp. When I test this with a pinned single message, it works. When I have the workflow running automatically with batches of 20 messages, the node preceding the code node can’t be referenced after the code node. I read through the “Item linking in the code node” article but am a bit of a novice with javascript so I was wondering if someone could point me in the right direction so I can reference a node that’s 2 previous to the code node in a node that comes after the code node. There also seems to be an issue where the code node doesn’t return results when the start of the chain is more than 1 message. So the issue is both with the code node processing correctly and also the variables be referenced later in the workflow.

What is the error message (if any)?

PropertyValues[itemName] is not iterable and anotherone mentioning the need to item link

Information on your n8n setup

  • n8n version: 1.21
  • Database (default: SQLite): PostGresql
  • n8n EXECUTIONS_PROCESS setting (default: own, main): queue
  • Running n8n via (Docker, npm, n8n cloud, desktop app): EKS
  • Operating system: Alpine Linux

Hi @Hidden_Squid, unfortunately I don’t know how the data coming from your HTTP Request node, but it seems you are looping through the json.messages.matches field of your incoming items and then return a single one of the JSON objects in this array. This is somewhat problematic as it means you’re not specifically returning a full n8n item (including a json field) but just the content of the json field.

n8n will wrap your return value implicitly inside json upon returning the result, but this means you don’t get a chance the add the pairedItem field to your items (which lives on the same level as json, documented here).

That said, do you even have more than one item coming from your Convert Message Time to Epoch node here? If not, perhaps you want to ignore the complexity that comes with linked items and simply use expressions like {{ $('Convert Message Time to Epoch').first().json.json.channelIdentity.teamId }} here (which would always reference the first item from Convert Message Time to Epoch rather than relying on linked items).

so I think this ended up being my code and the data not being there when it was expected. I changed the conditions around a bit and got it to work without error. Appreciate your help here.

1 Like

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