Use of getWorkflowStaticData

Hi everyone,

I want to send last x number of tweets to a Slack channel every minute. But I want to check the tweets that have already been posted on Slack and not send them again. I am trying to achieve this by using a function node and getWorkflowStaticData. However, so far I couldn’t manage to filter the old tweets and not send them again. Could you please help me to understand what is wrong with the code below?

Thanks in advance.

const staticData = this.getWorkflowStaticData('node');
     if (!staticData.lastExecution) {
	return items; } 
     else { 
             const lastExecution = staticData.lastExecution;
	     staticData.lastExecution = new Date().getTime();
 	     delete staticData.lastExecution;
	}

Welcome to the community @iremP!

Honestly does the code for me not look like it got written to solve your specific problem. Normally I would post the correct full code, but as it is part of an assignment we gave you for a job (and it is actually the only complicated part) would it totally defeat the purpose.

So all I can say here is, that you should probably check out again how static data works. Here the documentation:

There are also some other examples in the forum.

Apart from that would you have to iterate over all tweets (items) and then check which ones got posted since the last execution. The ones that got already processed before (identify via ID or post-time) you filter out and all others you let pass through.

1 Like

Hi @jan,

Thanks for your help. I will follow your suggestions and have a deeper look into it.

1 Like