Combined expression help

Hi all - I have what may be a JavaScript question related to expression syntax. In my workflow I have three nodes:

  1. Extract event fields
  2. Find events
  3. Prepare data (an edit fields/set node)

In the last node, I want to set an expression that uses a value (fieldName) from the first node as the lookup value on the second node.

An example would be if the first node’s fieldName value = ‘Birthday’ then I want my last node to have a field that gets the value from the previous (2nd) node like $json.Birthday. It has to be dynamic though as fieldName will change with each execution.

In my head it looks like this, but I know the syntax is wrong:

{{ $json. + $('Extract event fields').item.json.fieldName }}

Any ideas on how I can pull this off? Can I do this in an inline expression or should I use a code node just before?

1 Like

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

@hndmn , you could do something like this,

{{ $json[$('Extract event fields').item.json.fieldName] }}
1 Like

Yes, thank you! I hadn’t considered using the square brackets.

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