How does itemMatching and currentNodeinputIndex work?

In the docs (Built in methods and variables reference - n8n Documentation) the function $("<node-name>").itemMatching(currentNodeinputIndex) is referenced but I haven’t found many examples of how to use it.

How do I get the currentNodeinputIndex?

I’ve used the number 0 with success sometimes, but today that stopped working on a workflow of mine.

A related question. When using these variables in a code node, does it matter if I’m using “Run Once for All Items” vs “for each”?

Hi @j0dan, tbh I’ve never used that one and simply fetched whatever I needed outside of the Code node (before running any code). Perhaps you want to simply put a Set node in front of your Code node and use $("<node-name>").item in the Set node? $("<node-name>").item also seems to work when using the Code node in the “for each” mode.

As for the documentation of the .itemMatching() method, I’ll leave a note for the docs team so they consider adding an example.

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