Interval per item

Hey,

Let’s say that I have a list of items, each with a value that is functioning as a schedule (hour of the day).

How would you structure the nodes?

[
   {
      "pageId":"1",
      "pageName":"Something",
      "projectId":"1",
      "url":"url",
      "frequency":[
         11,
         16
      ],
      "team_id":1
   },
   {
      "pageId":"2",
      "pageName":"Something",
      "projectId":"1",
      "url":"url",
      "frequency":[
         10,
         13,
         18
      ],
      "team_id":1
   },
   {
      "pageId":"4",
      "pageName":"Something",
      "projectId":"3",
      "url":"url",
      "frequency":[
         12
      ],
      "team_id":1
   },
   {
      "pageId":"6",
      "pageName":"Something",
      "projectId":"3",
      "url":"url",
      "frequency":[
         12
      ],
      "team_id":1
   }
]

Thanks in advance,
Martin

Hi Martin,

What do you want to do with the values? Sort the items on the values? Or do you want to do something at those times?

Hi Bram,

(hobby project of mine)

Yes, I want to call a http request per the schedule of the items in list.

Thanks,
Martin

So for example, if you have it at 18 call the http request at 18?

That is correct.

I would probably have a external datasource to store the schedule and then run a workflow every hour or so retrieving the values from that external datasource that need to be triggered.
Would that be what you are looking for?

Yes, that is what I have.

So you’re thinking an IF matching based on now()?

No, I would set a date time on which it would need to trigger. So in the external system you would have a date to filter.
You can then call the external table with a filter and only get the records you need to trigger.

EDIT:And then have it set the same record for the day after so it gets send to the back of the schedule.

So if I just add a wait and kick it of each 24 hours, would this work?

Meaning that I don’t do the hours of the day, but just “each 11 hours” for example.

Not sure if the wait node would be the best idea.
Could you give some more details on the goal of this workflow. Would make it a lot easier to help you. :sweat_smile:

I want to run a http request based on a frequency set from an item list. Each item can have different values.


const date = new Date();const numOfHours = item.frequency[0];
date.setTime(date.getTime() + numOfHours * 60 * 60 * 1000);

// Add a new field called 'myNewField' to the JSON of the item
item.dateToRun = new Date;

console.log('Done!');

return item;

I made an attempt/failure to print the current day + the hours from items.frequency

I am totally fine with having “each x hours” per items. It doesn’t have to be e.g. hour 10 & 18 of the day.

Then we are back at using an external table with the schedule.
Could also get every record and check the time with an if node like you suggested.
As long as you dont have too many records this would be fine.

The interval is from an external table.

I just need to know how to set a schedule based on the external table, on item level.

So just checking the items if they contain the hour that it is right now would do the trick? And then schedule the workflow each hour?

Yes that would work.

Ill fix a quick example tomorrow morning for ya.
Not at pc now.

1 Like

Hi @ericsonmartin

Would this work for you?