It there any ideas about process instance variables

As you know, when we work on a workflow instance, we can set/get some variables to process instance level. so we can use it in any nodes of process instance.

does n8n have this idea?
how i set some values in current workflow instance and use that values in later nodes?

Hi @Shawn-Yang-AWX, welcome to the community :tada:

You should be able to reference any previous value through expressions in n8n. In this example, the last node will read the original value from the “Set Initial Value” node:

Example Workflow
{
    "nodes": [
      {
        "parameters": {},
        "name": "Start",
        "type": "n8n-nodes-base.start",
        "typeVersion": 1,
        "position": [
          240,
          300
        ]
      },
      {
        "parameters": {
          "keepOnlySet": true,
          "values": {
            "number": [
              {
                "name": "myValue",
                "value": 123
              }
            ]
          },
          "options": {}
        },
        "name": "Set Initial Value",
        "type": "n8n-nodes-base.set",
        "typeVersion": 1,
        "position": [
          460,
          300
        ]
      },
      {
        "parameters": {
          "keepOnlySet": true,
          "values": {
            "string": [
              {
                "name": "foo",
                "value": "bar"
              }
            ]
          },
          "options": {}
        },
        "name": "Set Something Else",
        "type": "n8n-nodes-base.set",
        "typeVersion": 1,
        "position": [
          680,
          300
        ]
      },
      {
        "parameters": {
          "values": {
            "string": [],
            "number": [
              {
                "name": "myValue",
                "value": "={{$item(0).$node[\"Set Initial Value\"].json[\"myValue\"]}}"
              }
            ]
          },
          "options": {}
        },
        "name": "Read Original Value",
        "type": "n8n-nodes-base.set",
        "typeVersion": 1,
        "position": [
          900,
          300
        ]
      }
    ],
    "connections": {
      "Start": {
        "main": [
          [
            {
              "node": "Set Initial Value",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Set Initial Value": {
        "main": [
          [
            {
              "node": "Set Something Else",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Set Something Else": {
        "main": [
          [
            {
              "node": "Read Original Value",
              "type": "main",
              "index": 0
            }
          ]
        ]
      }
    }
  }

So you can essentially use any node of your workflow as a variable storage :slight_smile:

1 Like