Difference between getWorkflowStaticData type global and node?

Describe the problem/error/question

Hi Team,

I need to understand the difference between $getWorkflowStaticData('global') and $getWorkflowStaticData('node'). I have read the https://docs.n8n.io/code-examples/methods-variables-examples/get-workflow-static-data/ article, but the results I am getting do not match what is described.

Thank you.

What is the error message (if any)?

NO

Please share your workflow

Share the output returned by the last node

I’ve add this code for different workflow,
When I run it for one workflow the value should be

  • executionTimeStamp: 2023-04-26T12:11:43.398Z
  • lastExecution: 1990-01-01T00:00:00.000Z
    BUT
  • executionTimeStamp: 2023-04-26T12:11:43.398Z
  • lastExecution: 2023-04-26T12:11:42.398Z ( it’s fetching the value from the another workflow last execution)

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Gouravdev, are you manually executing your workflow? Static data wouldn’t be available when doing so, making it rather hard to build and debug workflows relying on this.

So personally, I’d suggest you use an external datastore (any database would do) whenever you need to store data across multiple workflow executions.

Hi @MutedJam
No, the workflow is active and trigger on the cron job node.

my one workflow lastexcution time override the other workflow time.

When I run it for one workflow for the first time the value should be

  • executionTimeStamp: 2023-04-26T12:11:43.398Z
  • lastExecution: 1990-01-01T00:00:00.000Z
    BUT
  • executionTimeStamp: 2023-04-26T12:11:43.398Z
  • lastExecution: 2023-04-26T12:11:42.398Z ( it’s fetching the value from the another workflow last execution)

is it possible to have the last execution based on the workflow specific not global.

Hi @Gouravdev, both of your Function Item nodes use getWorkflowStaticData('global'); , so I am not sure what exactly you are expecting here tbh and where $getWorkflowStaticData('node') comes into play.

I just tried running your workflow only once (with a webhook trigger, so I can control more easily when it runs) and this is the result:

So the lastExecution value is set as expected for me.

As mentioned, my suggestion here would be to use an external database instead to avoid the confusion coming with static data.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.