Round robin leads assignment
In workflows documentation there is a brief expatriation on how to implement a round robin leads assignment - https://docs.twenty.com/user-guide/workflows/internal-automations#lead-assignment-round-robin
But i can't really find a code example for the "Code action to determine next rep in rotation" step, nor any documentation for the code step of the workflow at all, could please somebody share?
Twenty Documentation
Internal Automations - Twenty Documentation
5 Replies
you can do something like this i guess:
you can add a step before to search all your active reps
Hi, thank you!
To be honest i couldn't really get the model you had in your example, should
lastAssignedRepId be a field of the model and reps a relation?
like i'm undestandifn the code, but don't clearly understand the data model it's working withlastAssignedRepId is an optional parameter of the function that is computed in the first step of the workflow "Search Records to find the last assigned rep".
reps are the list of the reps which can be assigned to a lead. It can be extracted from another search step.
Is that clearer? Don't hesitate to ask questions if still blurry
Thanks! Now i got it, i was confused at first on assigning values to the variables, but figured it out now.
The UI is a bit hard to get from the first time, i'm personally missing a hover on the assignment button.

Thanks for the report
@Thomas