Is this an ok way to do something recursively?

Hello, I am currently recursively updating each user one at a time using api workflows.

Every hour the API Endpoint is called, and it makes changes to a specific user based on Item #(do a search for user update number) then it adds +1 to that "user update number, and reschedules itself once again. The “user update number” will then go back to 0 once it is greater than the number of users.

I am worried however that if there are many users, this will break. As I am not sure what will happen if it takes longer than an hour to do this, and it starts to schedule over itself. It is also not at all fast, this method takes around 20 or 30 seconds per user. Just looking for ideas. Thanks!

There are others that do a lot more with recursive API Workflow scheduling who will probably chime in here. (I’ve only dabbled in it - I find server side workflows operating on any sort of list of anything to be too slow to do anything useful, quite frankly… but that’s just me. People really do use them.)

Anyway, I do think that this could rack up way too many pending workflows and I’m not sure what happens when this thing starts over and the previous kickoff of the recursive process is not finished…

I do want to ask though: What is it that you need to do hourly on your entire User base… and are your really sure you need to do it?

Basically I am just giving each user one “credit” every hour, which is what I am doing this for, I would do a normal “change a list of things”, but that will time out at after around 50 entries.

Have you considered just calculating this whenever needed, based on a starting and ending date/time?

1 Like

That could work, although I am not sure how to do the calculations for time / date to make this possible.

The basic calculation is easily done by subtracting the start date from the end date which can then be represented as hours.

1 Like

Going to try this out, thanks for the idea!

1 Like

Yep. That’s all you need to do.