I’d like to be able to set variables that would be available at the workflow level scope - so any node inside a workflow would be able to access the data. The motivation for this is two-fold.
My use case:
make it easier to set values that could be used throughout the workflow. I know you can do this using a code node, or set node, but if you have multiple triggers in one workflow, you’d have to configure multiple versions of the set/code node to configure these values
make it easier to migrate nodes from different environments - for example, dev/test/prod. You could essentially copy a workflow from test to prod and the variables that would change would already be configured in the workflow settings so your workflow would need minimal modifications between environments.
I think it would be beneficial to add this because:
It will help the developer story that works in multiple environments and reduce the amount of work it takes to change things like Base URL values for a workflow that uses lots of HTTP requests.
Any resources to support this?
Not yet
Are you willing to work on this?
I would work on this - I’d need some high level pointers to get started but I could certainly work on it.
This is exactly why we released the variables feature and the upcoming source control feature is the next stage of that so you can do exactly what you are after. These are global variables though rather than workflow level and they can’t be set from a workflow but for setting a URL you can do that with no problem.
@Jon hey Jon, I believe there is still merit for workflow level variables, unless I am missing a key feature/functionality.
In my experience (this is a new account but I’ve used N8N since the beginning of the year and have some 15-20 production workflows but absolutely do not claim to be an expert), the flow gets very messy when needing to reference Set nodes in workflows with multiple branches, loops and code nodes executing on all items. I find that the “reference” to previous nodes often gets broken and a combination of merge and set nodes need to be used where a workflow level variable could be used instead. But again, maybe I’m not using N8N properly.
Would absolutely support a $workflow.vars. or similar. Would also appreciate any enlightenment in case I am missing how N8N should be used.
You are not wrong, I would also like variables that I can read at a workflow level. For now the only option is to use staticdata which exists at a workflow level or use an external database to store data in and pull it out / set it as needed.
At the moment though our variables are static and can’t be changed but hopefully this will change in the future.
Any recommendations for such an external database? I guess I’ll go with spreadsheets for now, or is this known to impact performance a lot? Also, I guess I can use the $exections.id var to create a “scope” for these vars?
I developed a community node for n8n, named n8n-nodes-globals, which might have what you need. It lets you set up constant values that can be used in all your workflows.
Dear , ancient one. kindly help me, I’m new to n8n and need some assistance with my current workflow setup.
Use Case
I have two lists:
Expenses: A list of expense items.
Transactions: A list of transaction items.
Goal
I want to match each expense with a transaction. Specifically, I need to:
Loop through each expense.
For each expense, loop through the transactions to find a match.
When a match is found, remove the matched expense and the corresponding transaction from their respective lists to prevent duplicates in the next iterations.
Store the matched data temporarily.
Return the final results after all matches are processed.
Problem
I’m struggling to find a way to store temporary data for the matched expenses and transactions and to properly remove matched items from the lists. Could someone guide me on how to achieve this in n8n?
Juwt doing it, but sir @BramKn can i do it. In current setup. Can i create something live a storage to store data in it and remover it from the data i am using in flow , soni wont get dublicate. And at the end return this new data.