Using expressions for node inputs that are conditionally present

Hey folks, I’ve encountered this issue in a couple places, and it seems like there should be an obvious answer I’m missing.

There are a handful of integration nodes that have a “True/False” input, which determines whether the next input appears or not.

I can’t seem to configure both inputs with an expression, because once I configure the first input with an expression, the second input disappears.

For example, the GMail “Get Many Messages” node:

image

I want to configure it so that if $json.output.limit === -1, then all results are returned. If not, then the value of $json.output.limit should be used for the value of Limit.

But if I configure “Return All” with an expression, then “Limit” disappears, so I can’t put an expression there.

Is there an ideal way to handle this? I’ve been working around it by creating two separate nodes with different fixed “Return All” values and routing to the appropriate one, but that seems clunky.

Information on your n8n setup

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

Yeah, known UI quirk. When you make Return All dynamic, n8n hides the dependent fields.

Easy fix: Leave Return All set to False permanently.

Then use a ternary in the Limit field: {{ $json.output.limit === -1 ? 100000 : $json.output.limit }}

Setting limit to 100k works like Return All since n8n paginates automatically (unless you actually have that many emails!).

Let me know if that works.

2 Likes

Glory to you and your house!

And a follow-up - I would guess there’s not a similar workaround for this case, with the ClickUp “Get List” node?

Because if a list is folderless, then, you can’t specify any value for folder ID.

(Sidenote - is there an open GitHub issue for this? I couldn’t find one, but if not, I’ll create one.)

1 Like

Definitely create a Feature Request for it on the forum—it’s a common pain point that needs more visibility.

Ended up opening a GitHub issue for it, the team accepted it as a future enhancement: Unable to use expressions with both a conditional input and the dependent input · Issue #25803 · n8n-io/n8n · GitHub

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