Help

Assigning Collaborator in order (TRUE Round-Robin)

Topic Labels: Automations
2167 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Meghan_Weeder
4 - Data Explorer
4 - Data Explorer

Hello

I am trying to find a way to assign the collaborator field in order - Like a TRUE round-robin

We are currently running an automation where status is “Status A” and the Collaborator field is empty

THEN - run this script (below) and update the record.

const collaborators = [
    {name: "Person 1"},
    {name: "Person 2"},
    {name: "Person 3"},
    {name: "Person 4"},
    {name: "Person 5"}
]
const chosenOne = collaborators[Math.floor(Math.random() * collaborators.length)];
output.set("chosenOne", chosenOne.name)

This automation runs randomly - I need an automation that will assign 1,2,3,4,5 in order and then repeat that order.

2 Replies 2

hi @Meghan_Weeder,
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.

Hope this helps!

Alessio
Website: alessiomonino.com
Email: alessio.monino@gmail.com

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,

  1. Use a “Find records” action to find the one collaborator that is checked.
  2. Use a Update Record action to update the collaborator linked record of the triggering record to the record found in the “Find records” action.
  3. Use an Update Record action to clear the checkbox of the collaborator that was just used.
  4. 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.