Problem appending rows to Google Sheets with dynamic expressions

Hi everyone,

I’m trying to fill a Google Sheet with the results of an OpenAI LLM call. I’m using the Google Sheets node with the “Append Row” operation.

Here’s the strange behavior I’m facing:

  • If I set the Sheet ID via an expression (coming from a previous node that creates the Sheet in Google Drive) and fill the row with some fixed values, everything works fine.

  • But if I try to fill the row using an expression (to take the result of a previous node), I get an error saying that the Sheet ID is now undefined.

Has anyone faced this issue? Is there something I’m missing when using dynamic values for both the Sheet ID and row data?

Thanks in advance!

Error message:**Can not get sheet ‘By ID’ with a value of ‘undefined’

Workflow: The instructions I’m giving to the LLMs are very long, so if I paste all the workflow, I’m exceeding the character limit. That’s why I’m only sharing the last part of it (hope is enough).

It is possible that your JSON ID doesn’t know where to find the ID because two branches are arriving at your Excel spreadsheet. Maybe you could try replacing your JSON expression with

{{ $(‘Copy output_rubrica template sheet’).item.json.id }}

Thanks @NeoNormal for your quick answer.

I’ve tried that - using the “full path” to every variable - and I’m still having the same issue.
Then, I thought that maybe if I changed the paths of all variables in the workflow, it could work, but I’m starting to have the same issue in every node. This screenshot summarizes the problem:

Do you have a switch node or any conditional nodes in your workflow?
If so, you can try removing them one by one to identify where you are losing your data.

If you have code nodes, make sure you add at least one.

pairedItem: 0

at the end of your node

Item linking | n8n Docs

I see that you are using the split node, If you didn’t you can try to use the option

Include

Selected other fields

Fields To Include

The data you want to keep after this node

If you want to keep all data, juste select “All other fields