Execution vs. getWorkflowStaticData

Hi everyone,

For my education, the built in execution vs. getWorkflowStaticData means that the execution custom data is deleted after the execution is over while getWorkflowStaticData lives as long as the workflow is active?

In my workflow I have an access token which lives for 24 hours, afterwards it requires renewal. So, I was thinking to store it in the workflow static data and only renew it if it expired:
const workflowStaticData = $getWorkflowStaticData(‘global’);

// get new access token
workflowStaticData.accessToken = $input.first().json.data[‘session-token’]
// set timestamp of new access token
workflowStaticData.timestamp = $input.first().json.data[‘session-expiration’]

return [
{
// data: $input.all(),
accessToken: workflowStaticData.accessToken,
accessTokenTimestamp: workflowStaticData.timestamp,
// today: $today
}
];

So, when the workflow executes every hour, the if block checks for this value and only renew the token if it expired.

What do you think?

Things put in $getWorkflowStaticData, as far as I can tell, survive as long as the workflow exists (active or not). It seems like it is scoped by workflow id.

What you are describing should work, but…

  1. You might be able to get a generic Credential type to do the expire-check/update handling for you.
  2. There could be issues if more than one copy of the workflow runs at the same time (conflicting update timing for the static data values). Do some testing to observe how this actually behaves in your scenario.

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