# Item Linking with Code Node

**URL:** <https://community.n8n.io/t/item-linking-with-code-node/35462>\
**Category:** Questions\
**Tags:** expressions, code\
**Created:** [January 17, 2024, 9:30pm UTC](https://community.n8n.io/t/item-linking-with-code-node/35462 "2024-01-17T21:30:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hidden\_Squid](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@Hidden\_Squid](https://community.n8n.io/u/Hidden_Squid)\
**Post date:** [January 17, 2024, 9:30pm UTC](https://community.n8n.io/t/item-linking-with-code-node/35462/1 "2024-01-17T21:30:18Z")

</div>

## 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

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [January 22, 2024, 11:44am UTC](https://community.n8n.io/t/item-linking-with-code-node/35462/3 "2024-01-22T11:44:03Z")

</div>

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](https://docs.n8n.io/data/data-mapping/data-item-linking/item-linking-code-node/)).

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).

---

<div class="post-metadata">

**Author:** ![Hidden\_Squid](https://avatars.discourse-cdn.com/v4/letter/h/838e76/32.png) [@Hidden\_Squid](https://community.n8n.io/u/Hidden_Squid)\
**Post date:** [February 29, 2024, 3:24pm UTC](https://community.n8n.io/t/item-linking-with-code-node/35462/4 "2024-02-29T15:24:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [March 7, 2024, 3:24pm UTC](https://community.n8n.io/t/item-linking-with-code-node/35462/5 "2024-03-07T15:24:57Z")

</div>

Closed on March 7, 2024, 3:24pm UTC

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