Set node only setting first row

Hi guys!

I’m having a bit of trouble with a set node.
I’m using the notion node to get a database name, then I pass that name to a set node under a text variable.

My issue is that I’m only getting that variable set on the first row. I didn’t find anything related to this on the documentation nor any posts here.

Can you please help me out?

Hi @Daniel_Barra, hope you’re having a good day? Most nodes run once for each item, so it sounds like for your second (and subsequent items) there is no item. In that case could try an expression like {{$items("My Node")[0].json["foo"]}} where My Node is your Notion node and foo is the field with the database name.

The $items() method would always refer to all items of the current or previous nodes, so by using [0] you reference the very first item regardless of how many items you have.

Example Workflow

(This uses an HTTP Request and an Item Lists node to get some example items.)

Alternatively, if your Set node following the Notion node afterwards only returns one item, you could use the Merge node in Multiplex mode. This would also add the single field to each item:

Example Workflow

Hope this gives you some pointers! Let me know if I misunderstood you here or you have any further questions on this.

1 Like

Thank you so much @MutedJam !

It worked like a charm.

I’ll explain below exactly what I did.

image

This is the final structure of that part of the workflow.
On the SET node, I had to activate the option Execute Once and the Keep Only Set options.


Then using multiplex option of the MERGE node, it worked perfectly.

Once again, thanks for the help!

1 Like

Awesome, glad to hear that. Thanks so much for confirming and sharing your approach!

Hi, regarding this how works this in 2023 ? How can i get only the first line of items ?
Regards,
Stefan

Hey @Stefan,

It is probably worth opening a new topic but to answer your question the old method should still work. Below is a workflow that shows both the old and new ways in the set node. You can find more about this here: Built in methods and variables reference - n8n Documentation

1 Like

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