I actually recently worked in a similar use case for a client. He needed to make sure that each of his employees received the same number of tasks (and each new task would be allocated to an employee as soon as it was created). The approach I took is having a rollup field in the employee table that would count the number of tasks that had been assigned to each employee. Then from the script I would check all the employees and check which employee had the lowest number of tasks assigned to him. Then I would assign the task to that employee.
In your case, if the order of the collaborators is also important, you could add a field called “Ranking” or something similar in your collaborators table. Then when the script runs, it would first check for the collaborator with the lowest number of tasks and, in case of a draw, select the member with the lowest/higher ranking.
Is your collaborator field a linked record field? If not, turning it into a linked record field would enable you to assign the round-robin without using a script at all.
In your collaborators field, have the following fields
a checkbox field indicating the next collaborator to be assigned. This checkbox should be selected for only one collaborator and will be managed by the automation
a linked record field stating who is the next collaborator after the current one. Make sure that every collaborator is linked in a circular fashion.
When the automation runs,
Use a “Find records” action to find the one collaborator that is checked.
Use a Update Record action to update the collaborator linked record of the triggering record to the record found in the “Find records” action.
Use an Update Record action to clear the checkbox of the collaborator that was just used.
Use an Update Record action to set the checkbox of the linked “next” collaborator.
Note that when picking out the record ids for the Update Record actions, you will have to “make new list” of the values from the “Find records” action.
Note that this will assign collaborators in a circular fashion–it will not identify the collaborator with the fewest tasks. That requires a different logic, and is best done in a script (although there are ways of managing it without a script).
If you want to use a script, I also recommend that you do not hard code your list of collaborators in the script. A good script can to adapt to any number of collaborators being added or removed without having to edit the script.