My static data does not work

Hello,

I wanted to do something with only new RSS items, I built that:

{
  "nodes": [
    {
      "parameters": {
        "interval": 10
      },
      "name": "Interval1",
      "type": "n8n-nodes-base.interval",
      "typeVersion": 1,
      "position": [
        -10,
        1940
      ]
    },
    {
      "parameters": {
        "functionCode": "// Get the global workflow static data\nconst staticData = getWorkflowStaticData('global');\n\n// Access its data\nconst lastData = staticData.lastExecution;\nconst firstItem = items[0].json.isoDate;\n\nif(lastData == undefined || lastData < firstItem){\n  staticData.lastData = firstItem  \n  return items.slice(0, 1)\n}\nelse{\n  return [];\n}\n"
      },
      "name": "Function3",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        300,
        1920
      ]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": "4456786d-dbb4-4fa5-82c6-b67f22f72ef9",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Name|title",
              "title": "={{$json[\"title\"]}}"
            },
            {
              "key": "Property|date",
              "date": "={{$json[\"isoDate\"]}}"
            }
          ]
        }
      },
      "name": "Notion",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 1,
      "position": [
        580,
        1910
      ],
      "credentials": {
        "notionApi": "[email protected]"
      }
    },
    {
      "parameters": {
        "url": "https://rss.app/feeds/t9QEL151qMrE4X5s.xml"
      },
      "name": "RSS Feed Read3",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [
        140,
        1930
      ]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$items().length}}",
              "operation": "larger"
            }
          ]
        }
      },
      "name": "IF2",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        440,
        1920
      ]
    }
  ],
  "connections": {
    "Interval1": {
      "main": [
        [
          {
            "node": "RSS Feed Read3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function3": {
      "main": [
        [
          {
            "node": "IF2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Feed Read3": {
      "main": [
        [
          {
            "node": "Function3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF2": {
      "main": [
        [
          {
            "node": "Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Unfortunately it put in notion last one every 10 second, could I ask what did I wrong?
I read in docs that running manually staticData will not work, how could I check what’s going on with my ‘code’ how to debug it?

I found here working nodes, but I cannot understand what’s wrong with mine, so I wanted kindly ask :sweat_smile:

Thanks!

You can still debug it by using console.log() in the function node. You can see whatever you printed in the function node in the explorer console.

But getWorkflowStaticData() return always empty array when run workflow manually, am I right?

Hey @Shirobachi,

When running the getWorkflowStaticData() manually, you won’t get the expected output. You will have to run the workflow in production to see the results. You can read more about it here: Function | Docs