Only new data Google Sheet

Hi everyone !

I’m really new into n8n and i have a question.
I have to generate automatically invoice from my google sheet. I’ll prepare a google doc template and i want to generate pdf invoice everytime i add a new row in my google sheet.
I don’t know how to define that only the new rows will be concerned.

I tried this https://n8n.io/workflows/864 but it’s not workin (maybe i didn’t change the right parameters)

Thank you for your help !

Hi @David_Mo,

Welcome to the community! I hope you’re having a good day?

The workflow you have linked uses getWorkflowStaticData in its Check if new data Function node to store which values from the ID column have been processed. This method is documented here and has some restrictions compared to other methods of persisiting data, one of which is:

The static data cannot be read and written when executing via manual executions. The data will always be empty, and the changes will not persist. The static data will only be saved when a workflow is active.

Could this possibly be why it’s not working for you? If not, could you share your workflow (removing any confidential data) and a description of the error?

Thanks so much!

3 Likes

Hi @MutedJam,

First of all thank you for you answer !
You’re right i didn’t know, i activated the flow and the code is partially working but now i think it’s because my function.

const new_items = [];
// Get static data stored with the workflow

const data = this.getWorkflowStaticData("node");
data.mail = data.mail || [];
for (let i = items.length - 1; i >= 0; i--) {

// Check if data is already present
  if (data.mail.includes(items[i].json.mail)) {
    break;
  } else {

// if new data then add it to an array
    new_items.push({
      json: {
       // id: items[i].json.ID,
        //name: items[i].json.Name,
        mail: items[i].json.mail
      },
    });
  }
}
data.ids = items.map((item) => item.json.mail);

// return new items
return new_items;

i have a column named “mail” in google sheet and i want to check if there is a new row

Again, thank you

Hi @David_Mo, have you had a look at this blog post by @harshil1712? It explains the polling process very well and also covers the topic of checking whether a Google sheet contains new data.

2 Likes

Hi @MutedJam,
I looked at it thank you now it’s working !

1 Like

Awesome, thanks a lot for confirming and have a great weekend!