Check if a specific workflow is running

i’m trying to check a workflow is running but even running it returns the value as “isActive”: false

Did I do some wrong configuration?

{
  "nodes": [
    {
      "parameters": {
        "url": "http://localhost:5678/rest/executions-current",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        -1760,
        1160
      ]
    },
    {
      "parameters": {
        "functionCode": "const executions = items[0].json.data.filter(execution => execution.workflowId.toString() === '30');\n\nreturn [\n  {\n    json: {\n      isActive: executions.length > 1,\n    }\n  }\n];\n\n\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        -1560,
        1160
      ]
    }
  ],
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

thank you for your help

If you just want to check the current workflow is running, then change the isActive: executions.length > 1 to isActive: executions.length > 0.

You can also use $workflow.id for the comparison instead of a static value: execution.workflowId === $workflow.id.

2 Likes

this is exactly what i was looking for, thank you very much

1 Like