Access to the properties of the "SET" node

Hello,
how do i access the values contained in the properties set by the SET node inside an expression, without specifying the set node name?

In the example below, I set the “string” property to “value1” if the switch is set to 0, and to “value2” if the switch is set to 1.
In the execute command node, and in the read binary node, I would like to be able to access this value.

Below is the code of the example in question:

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        260,
        330
      ]
    },
    {
      "parameters": {
        "dataType": "boolean",
        "value1": "={{$json[\"property\"]}}",
        "rules": {
          "rules": [
            {
              "value2": true
            },
            {
              "output": 1
            }
          ]
        }
      },
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        760,
        330
      ]
    },
    {
      "parameters": {
        "values": {
          "boolean": [
            {
              "name": "property",
              "value": true
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        540,
        330
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "string",
              "value": "value1"
            }
          ]
        },
        "options": {}
      },
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1020,
        210
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "string",
              "value": "value2"
            }
          ]
        },
        "options": {}
      },
      "name": "Set2",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1020,
        450
      ]
    },
    {
      "parameters": {
        "command": "="
      },
      "name": "Execute Command",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        1270,
        330
      ]
    },
    {
      "parameters": {
        "command": "=cd string"
      },
      "name": "Execute Command1",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        1470,
        330
      ]
    },
    {
      "parameters": {
        "filePath": "string"
      },
      "name": "Read Binary File",
      "type": "n8n-nodes-base.readBinaryFile",
      "typeVersion": 1,
      "position": [
        1680,
        330
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "Execute Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set2": {
      "main": [
        [
          {
            "node": "Execute Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Command": {
      "main": [
        [
          {
            "node": "Execute Command1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Command1": {
      "main": [
        [
          {
            "node": "Read Binary File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Thanks so much

You can probably add a noOp node before the Execution Command and reference the output of that node in the execute command node. That should solve the issue.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -1290,
        190
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [],
          "number": [
            {
              "name": "data",
              "value": 1
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -1050,
        190
      ]
    },
    {
      "parameters": {
        "value1": 1,
        "rules": {
          "rules": [
            {
              "operation": "equal",
              "value2": "={{$node[\"Set\"].json[\"data\"]}}"
            }
          ]
        }
      },
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        -830,
        190
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -540,
        0
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "name": "Set2",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -540,
        190
      ]
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -250,
        120
      ]
    },
    {
      "parameters": {
        "command": "={{$node[\"NoOp\"].json[\"data\"]}}"
      },
      "name": "Execute Command",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        -50,
        120
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set2": {
      "main": [
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NoOp": {
      "main": [
        [
          {
            "node": "Execute Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
2 Likes