How to save/pin data between executions

Hi! First thanks for the awesome tool, i really have fun :heart_eyes:
I’m stuck in some workflows so i’m coming out… I’ve searched in the forum and the existing workflows, but couldn’t find anything similar - if there is, please let me know. If not, I’d be glad to share the workflows when i’m done!

What i want to achieve

Create a list in a newsletter app (Sendinblue, Mailjet, Mailchimp), import contacts in this list and automatically update it every day.

Where i’m stuck

Saving the list ID for next executions.

What i did so far

I’m going to take the example of Sendinblue.
I create a list in Sendinblue, which gives me a list ID, then I can import my client’s mails in the Sendinblue list thanks to the list ID. This part works well.

What i need

I would like to keep this list ID in memory, for when the update is done automatically, the list ID is passed in the request with the new contacts. Ideally, it would be as if the list ID was “pinned” after the node “2. Sendinblue - Create a contact list”.

So when the Cron task is launched, it would directly get the list ID without relaunching the first part of the workflow.

But i don’t think it’s possible, isn’t it? It would be like an equivalent of pinning the data for tests, except that it would be a pin between executions.

Another way would be to save the list ID and repeat the 2nd part of the workflow:

I’ve read some discussions pointing to the different ways to save data. I think it’s too much to save the list Id on another app or db or file.
So the only way would be to save as a static data I guess… But in the doc it’s said that "The workflow must be active and called by a trigger or webhook to save static data. " → in my case, the workflow is launched manually the 1st time. It won’t work, will it?

I also feel like i might be missing something very simple :sweat_smile:
The workaround I have for now, is just copying the list ID, and pasting it in the next node for next executions. But as this worfklow would be configured by people not familiar with n8n, i would like to make the thing easiest as possible for them.

Any help would be greatly appreciated :pray: Thanks a lot in advance :slight_smile:

You’re correct that static data won’t be saved between executions unless you:

  1. Are using an automatic trigger node (such as Schedule)
    and
  2. Have activated the workflow

To work around this, you could set the workflow up with two Schedule triggers. The first should start the path where you get the data (where you are currently using the manual trigger). The second should start your main workflow (as you are already doing).

Set the first Schedule node to run frequently (say, every 30 seconds), save the workflow, and activate. Let it run and load the data. Then pause the first schedule node.

Here’s a shorter example to test. I kept the interval short for testing purposes, so deactivated the second Schedule node to make it clear what was happening. To test this out:

  1. Import the workflow below into a new workflow (docs)
  2. Save and activate
  3. View the Executions list to confirm it’s running and setting data (docs)
  4. Pause the 5 second node, enable the 10 second node, and save
  5. View the Executions list again to confirm it’s now running and still getting data

Hi Deborah, thanks a lot for your reply! :pray:
After writing the post I also thought about a first schedule trigger, but i was wondering if for our people who are newbies it’s not more complicated than copy/pasting the list ID :grimacing: i also like the fact that with manual trigger they will see the execution going and can understand how it works… I think i’ll go with the copy/paste or saving the id in a file…And making a feature request for a “pin between execution” thing :smiley:

Anyways your worflow is sooo useful, it was the example i needed to really understand how to set and get static data.
I’m still wondering: if you want to access a node static data, where would you put the code? Because in the doc it is said

The node static data is unique to the node. Only the node that set it can retrieve it again.

But i can’t see a way to put code inside of a specific node (http node for instance).

Thanks again! :star_struck:

Setting data in the node is the same pattern as for the workflow. Try this in a Code node:

const thisNode = $getWorkflowStaticData('node');
thisNode.oranges = "orange";
console.log(thisNode);

I am updating the docs to make this clearer.

1 Like

Thank you very much

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