# Set global variables for workflow (self-hosted)

**URL:** <https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650>\
**Category:** Questions\
**Created:** [February 27, 2025, 9:08pm UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650 "2025-02-27T21:08:36Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbruner](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sbruner/32/33451_2.png) [@sbruner](https://community.n8n.io/u/sbruner)\
**Post date:** [February 27, 2025, 9:08pm UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/1 "2025-02-27T21:08:36Z")

</div>

## Describe the problem/error/question

I want to set a variable like $id that I can use anywhere in the workflow. A few different nodes might set it, so I can’t reference the node. Ideally, I would like to:  
Set it like:` var $id = "123"`  
And use it in a node like: `$id`.

Thank you for the help!

## Please share your workflow

Here’s a simplified version of what I’m thinking.

## Information on your n8n setup

- **n8n version:** 1.75.2
- **Database (default: SQLite):**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via:** Docker

---

<div class="post-metadata">

**Author:** ![n8n](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/n8n/32/196425_2.png) [@n8n](https://community.n8n.io/u/n8n)\
**Post date:** [February 27, 2025, 9:08pm UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/2 "2025-02-27T21:08:38Z")

</div>

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:**

---

<div class="post-metadata">

**Author:** ![Ruslan\_Yanyshyn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ruslan_yanyshyn/32/15080_2.png) [@Ruslan\_Yanyshyn](https://community.n8n.io/u/Ruslan_Yanyshyn)\
**Post date:** [February 27, 2025, 9:14pm UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/3 "2025-02-27T21:14:51Z")

</div>

Hey @sbruner You can use `Crypto node` for this

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/e/6/e670fdb42f05480c1521d5bb649c4e83ebe2f51d.png)

---

<div class="post-metadata">

**Author:** ![sbruner](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sbruner/32/33451_2.png) [@sbruner](https://community.n8n.io/u/sbruner)\
**Post date:** [February 28, 2025, 1:23am UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/4 "2025-02-28T01:23:08Z")

</div>

Thank you for the reply. Can you explain how I would reference “$id” in another node?

---

<div class="post-metadata">

**Author:** ![Ruslan\_Yanyshyn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ruslan_yanyshyn/32/15080_2.png) [@Ruslan\_Yanyshyn](https://community.n8n.io/u/Ruslan_Yanyshyn)\
**Post date:** [February 28, 2025, 1:34am UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/5 "2025-02-28T01:34:18Z")

</div>

In any node you can reach prevues nodes by it name `{{ $("Node name").json }}`. Look at this example

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/b/1/b1deb28632d280c12a4afc7ad21b66dc12a6e673.png)

---

<div class="post-metadata">

**Author:** ![sbruner](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sbruner/32/33451_2.png) [@sbruner](https://community.n8n.io/u/sbruner)\
**Post date:** [February 28, 2025, 1:53am UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/6 "2025-02-28T01:53:05Z")

</div>

In my example, I don’t know the Node Name. That’s my issue.

How do I get data from a node when I don’t know the name, and it’s not the previous node?

---

<div class="post-metadata">

**Author:** ![Daniel\_Lamphere](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/daniel_lamphere/32/39212_2.png) [@Daniel\_Lamphere](https://community.n8n.io/u/Daniel_Lamphere)\
**Post date:** [February 28, 2025, 1:56am UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/7 "2025-02-28T01:56:53Z")

</div>

start with an expression, type {{ }}, then type a $, you should then see options for all your previous nodes that are accessible

---

<div class="post-metadata">

**Author:** ![zaidsoomro](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/zaidsoomro/32/61317_2.png) [@zaidsoomro](https://community.n8n.io/u/zaidsoomro)\
**Post date:** [February 28, 2025, 1:59am UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/8 "2025-02-28T01:59:15Z")

</div>

On the left side panel you should see all available variables that you can drag and drop. If you don’t see anything that might be because to forgot to run the previous node.

Note: If there is an error in previous node you would also have to resolve it before you see the information in the left side panel.

---

<div class="post-metadata">

**Author:** ![Ruslan\_Yanyshyn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ruslan_yanyshyn/32/15080_2.png) [@Ruslan\_Yanyshyn](https://community.n8n.io/u/Ruslan_Yanyshyn)\
**Post date:** [February 28, 2025, 2:01am UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/9 "2025-02-28T02:01:08Z")

</div>

Sorry I a little bit confused. In the beginning of the workflow you would create $id in Crypto node and then reference to it by this node name. Do I miss something?  
Take look at this course created by N8N team.  
[Level One](https://docs.n8n.io/courses/level-one/)

---

<div class="post-metadata">

**Author:** ![sbruner](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sbruner/32/33451_2.png) [@sbruner](https://community.n8n.io/u/sbruner)\
**Post date:** [February 28, 2025, 3:04am UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/10 "2025-02-28T03:04:06Z")

</div>

I appreciate all the responses. Maybe I wasn’t clear. Please look at my initial workflow. Depending on the response of an IF Node, two different nodes will return an “id”. I don’t know which one, so I don’t know the name of the node. How can I get the data if I don’t know the name of the node?

---

<div class="post-metadata">

**Author:** ![Ruslan\_Yanyshyn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ruslan_yanyshyn/32/15080_2.png) [@Ruslan\_Yanyshyn](https://community.n8n.io/u/Ruslan_Yanyshyn)\
**Post date:** [February 28, 2025, 4:37am UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/11 "2025-02-28T04:37:20Z")

</div>

You can use OR operator, so your expression would be `{{ $("Node name_1").json || $("Node name_2").json }}`

---

<div class="post-metadata">

**Author:** ![sbruner](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/sbruner/32/33451_2.png) [@sbruner](https://community.n8n.io/u/sbruner)\
**Post date:** [February 28, 2025, 5:38pm UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/12 "2025-02-28T17:38:31Z")

</div>

I appreciate your responses. My example is a very simplified version of what I’m thinking.

As the subject says, I’m really looking for a way to set Global Variables for the workflow in N8N. Is that possible?

---

<div class="post-metadata">

**Author:** ![Ruslan\_Yanyshyn](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ruslan_yanyshyn/32/15080_2.png) [@Ruslan\_Yanyshyn](https://community.n8n.io/u/Ruslan_Yanyshyn)\
**Post date:** [February 28, 2025, 5:48pm UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/13 "2025-02-28T17:48:55Z")

</div>

Please look at [Create custom variables | n8n Docs](https://docs.n8n.io/code/variables/)  
As well to this post [Global variables on self-hosted](http://community.n8n.io/t/global-variables-on-self-hosted/26704)

---

<div class="post-metadata">

**Author:** ![hubschrauber](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/hubschrauber/32/46788_2.png) [@hubschrauber](https://community.n8n.io/u/hubschrauber)\
**Post date:** [February 28, 2025, 9:40pm UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/14 "2025-02-28T21:40:37Z")

</div>

> [@sbruner](#):
>
> I’m really looking for a way to set Global Variables for the workflow in N8N

~~It is a fairly new feature, so…~~ (Edit: Apparently that’s not true per one of the n8n guys, but still…). be sure to test thoroughly… so see if [$getWorkflowStaticData](https://docs.n8n.io/code/cookbook/builtin/get-workflow-static-data/) does what you need.

Edit: It is not exactly clear in the documentation whether this data is scoped to a specific execution of a workflow, or to the instance of n8n, crossing multiple executions of the workflow. The variable name “lastExecution” in the docs subtly suggests it is the latter, so I tested a bit to see how it works across multiple executions. I confirmed that a value set in one execution **does persist** to be read back in during later executions.

However, I **also** ran multiple executions of a workflow concurrently, where a “static data” variable gets set at the beginning, and checked at the end, to see if workflow executions were “stepping on” each other’s data, but… I couldn’t get that to fail, so maybe it is “thread safe” (so to speak). I would probably do some more testing before depending on this behavior in a production workflow.

Please mark this as the solution if it’s what you needed to get things working. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [March 7, 2025, 9:40pm UTC](https://community.n8n.io/t/set-global-variables-for-workflow-self-hosted/82650/15 "2025-03-07T21:40:49Z")

</div>

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