How to correctly use $evaluateExpression

Describe the problem/error/question

I’m testing $evaluateExpression in n8n.

The goal:

  • Store some JSON data (e.g. {"name":"John"}).

  • Store an expression string (e.g. "hi {{ $('set data').item.json.name }}").

  • Later dynamically evaluate the expression string using $evaluateExpressionin JS code block.

In production, the data and expression will both be strings coming from upstream nodes, so I need $evaluateExpression to resolve them dynamically.

What is the error message (if any)?

None

Please share your workflow

Share the output returned by the last node

{“result”: null}

Information on your n8n setup

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

Evaluations | n8n Docs

You can follow that instructions

Thanks for reply. im not trying to evaluate this workflow but trying to use $evaluateExpression in code block.
I’ve tried this doc Convenience methods | n8n Docs but didn’t help.

Ah sorry I dont get what u mean, in my n8n it’s working fine btw.

it output {“result”: “hi John”}?

Yes, exactly.
Which version in n8n are u?

version : 1.107.3
Using docker with env
-e N8N_RUNNERS_ENABLED=true
-e N8N_SECURE_COOKIE=false
-e DB_SQLITE_POOL_SIZE=1

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