Nested Loops

Dear all, I'm facing an issue with an automation that should do the following:

Given a Row in a table [Yearly_Attendance_Reg]

- For each row in another Table [Employees] -> Create new Rows in a third table [Register] 

- Repeat for N times N=12

Basically it is an Attendance register, and when a new row (=Year) is added in [Yearly_Attendance_Reg], for each employee in [Employees] a register has to be created in [Register] with all the days of the year, to set the working hours, the holiday hours and other columns.

In a first moment I used a Looped Action(2 nested Loops actually) triggered by the User, so pressing a button, the action was performed. The issue was that increasing the number of Employees it was very time consuming and was often exiting with time-out and having created only a part of the rows it had to create.

Then I tried to move the operations server-side: I created a WebHook in a Bot, triggered when a new row (=year) is added in [Yearly_Attendance_Reg]. The WebHook creates at a run, for all the rows in the [Employees] table, a monthly register and it works like a charm in few seconds. But the issue was that I have to create 12 months.

I tried different approaches:

1) a single BOT, triggered when a new row (=year) is added in [Yearly_Attendance_Reg], with a flow calling 12 times the same WebHook, each time increasing the month (awful, but if it was working i pretend it is nice :D) . 

2) Two BOTs, BOT_A triggered when a new row (=year) is added in [Yearly_Attendance_Reg], calling the same WebHook, hence creating one month (January) for all the employees and increasing month on exit. BOT_B, triggered when the new row (=year) is Edited in [Yearly_Attendance_Reg], hence when the month is increased and calling the same WebHook.

3) A Scheduler, that reads column [month_number] from [Yearly_Attendance_Reg] for the last [year]: if [Register] rows exist for the couple ([year],[month_number]) it increments the [month_number], otherwise it calls the WebHook and then increments the [month_number]. The Scheduler ha to run 12 times to create the whole Attendance Register.

I expected approach 1) to work linearly, but it goes in timeout at month 6. Approach 2 should instead call recursively BOT_B until the month counter is <12, but it is called just 3 times and stops at month 3.

I cannot figure out why approach 1) and 2) are timing-out (process stops before 300 seconds actually) and which could be the best solution to achieve the goal, and to be sure that increasing the employees' number will not create a timeout issue in the future. Have you any suggestion?

Thank you very much for you help!

Kind Regards

Lucy

PS: I din't attach screenshots because the post would become too long, but if they're needed I can add them.

 

Solved Solved
0 3 107
1 ACCEPTED SOLUTION

Hi Lucie,

Your issue seems to stem from platform limits (timeouts or max actions). Here are a few simple fixes:

  1. Single WebHook: Instead of calling the same WebHook 12 times, make it create all 12 months for all employees in one go (if possible). It's faster and cleaner.
  2. Batching: If you have many employees, split them into smaller groups (e.g., 500) and process each group in the same script or using a scheduler.
  3. Scheduler: Set up a bot that runs every X minutes to add one month at a time until the full year is done.

The key is minimizing round-trips and using bulk processing to avoid timeouts. If you can do everything with one WebHook, that's ideal.

Good luck! Let me know if you need more details. 😊

Cheers,
Jee

View solution in original post

3 REPLIES 3

Hi Lucie,

Your issue seems to stem from platform limits (timeouts or max actions). Here are a few simple fixes:

  1. Single WebHook: Instead of calling the same WebHook 12 times, make it create all 12 months for all employees in one go (if possible). It's faster and cleaner.
  2. Batching: If you have many employees, split them into smaller groups (e.g., 500) and process each group in the same script or using a scheduler.
  3. Scheduler: Set up a bot that runs every X minutes to add one month at a time until the full year is done.

The key is minimizing round-trips and using bulk processing to avoid timeouts. If you can do everything with one WebHook, that's ideal.

Good luck! Let me know if you need more details. 😊

Cheers,
Jee

Hi Jee,

many thanks for your answer! 
I implemented the third solution, but i was trying to test also the first and the second: 
1) In the WebHook body I should call the same action 12 times with different Row section (to change month). Could you please show me an example of multiple-actions webhook syntax? I'm not sure if i should add many action in the webhook body, or just one action with many Rows section (I can't find a resource for the syntax)

2) Could you suggest how to implement this? 

Thanks again!

Lucy

Hi Jee,

thanks a lot for your answer. 

  1. Single WebHook: I will try also this solution.
  2. Batching: can you suggest how to implement this?
  3. Scheduler: This is what I have implemented at the moment.

Cheers, 

Lucy

Top Labels in this Space