Make global expressions more easily accessible in Expression editor?

Disclaimer: I’m new to n8n and this might be a terrible idea :slight_smile:

I was stumped trying to get the current workflow name in a telegram msg node, and then stumbled upon this:

I then discovered I could put {{$workflow.name}} and it would work!

I think it would be awesome if in the left hand panel of the node’s expression editor, there were these global expressions made more discoverable.

Eg. currently it’s this:

Perhaps something like this would work where a Global set of expressions is also avail on left hand side?

To be honest is the Expression-Editor one of the things I want to improve (actually totally overhaul) for a very long time. In the beginning, there was simply way too much to be done so could not spend too much time on every single feature. Sadly did we still not get around to do that. So really like your suggestion. Would not be too much work to implement now but still could help users in this situation a lot.

2 Likes

Totally understand the situation, and appreciate all the hard work. Glad my suggestion resonates with you.

I think the main principal here I see is to try to avoid needing function nodes as much as possible, and make key programmatic elements more easily discoverable (without needing to search the community forums).

With a nested tree of “globals” available in the expression builder, if it’s easy to add now, I think it would be really work it ahead of a full overhaul. I can see everyone wanting this.

I’d even love to see stuff like “Current Date”, “Current Date and Time” etc in there. Could see several flavors of Moment/JS formatted friendly strings being done under the covers, which again, eliminates the need for function nodes.

Thanks @tmchow - as Jan mentioned, we know we want to overhaul the Expression Editor and currently we’re in the preliminary stages - collecting potential functionality spec + research. So this feedback is immensely useful from a product design perspective.

Other potential functionality we’ve identified would be access to simple “cell sheet functions” (like average() that you might find in Google Sheets). I’m hesitant to bandaid a globals list on left panel as the overhaul will likely reimagine that experience - we’d rather do it as part of a holistic redesign with ample UX testing and validation.

Having said that, for this reason we have created a JavaScript Snippets cheat sheet which focuses on time/ date vars/ functions (https://docs.n8n.io/reference/javascript-code-snippets.html#date-and-time ). Will work on adding some useful global vars there (incl. workflow name).

Please do let me know if there is additional functionality that you wish you had in the EE, or things you do often that is currently frustrating/ complicated to do via function nodes.

Thanks!

1 Like

Biggest issue is the discoverability of what’s available as I’m composing workflows. While global variables can be seen as functions (.getWorkflowName()), I think of them more as constants that I want easy discoverability of. I do this excel cell sheet like functions would work well for the long tail of functions that would be available.

I also think additional constraints/control over multiple executions in a node would be helpful to not need other control nodes. For example, I have this other convo going about this:

1 Like

Meanwhile, I’ve also just added the workflow variables to the JavaScript Code Snippets page: https://docs.n8n.io/reference/javascript-code-snippets.html#workflow-data

Hope that helps a bit with the discoverability :flashlight:

1 Like

@tmchow just wanted to let you know that I had a chat with Jan and we decided we can proceed with adding a globals list to expression editor and not block releasing that for the full-fledged overhaul of the expression editor. Verdict was that effort vs. benefit ratio just makes sense here.

Don’t have an exact timeframe as to when this will be ready, but am working on a concept this week so it’s definitely not hiding somewhere in a backlog :slight_smile: On that note, if you or any other users have other ideas for what would be useful globals - pls let me know on this thread!

4 Likes