Static Data & Workflow Variables in n8n
From the n8n cheat sheet · Code Node · verified Jul 2026
Static Data & Workflow Variables
Persist data between executions
javascript
// Get/Set Workflow Static Data
const staticData = getWorkflowStaticData('global');
// Read last processed ID
const lastId = staticData.lastProcessedId || 0;
// Update for next execution
staticData.lastProcessedId = currentId;
// Node-specific static data
const nodeData = getWorkflowStaticData('node');
nodeData.retryCount = (nodeData.retryCount || 0) + 1;⚠️ Static data only persists in PRODUCTION executions!
💡 Use for incremental processing (track last ID)
📌 getWorkflowStaticData("global") for workflow-wide storage
🔍 Custom variables ($vars) are read-only, set in UI