function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Evan ShueyEvan Shuey 

round robin trigger logic question

I have a question on how to build a round robin trigger. We are trying to replace our Distribution Engine by building our own. I beleive this needs to be done with a trigger and I will list requirements below...

We have a custom object that populates a record when an Opp is made. On the Opp we have different locations (sites) that can be populated based on where the customer is. Each location has different Solution Engineers (SE) that get assigned. This process needs to randomly assign an SE that is within the site. 

So the base logic is whenever an Opp is created with a "site," look at that site and update the SE on the Opp with the name of the next user within that site list.

We have 10 different sites with around 3 SE's each. I was thinking about using a custom setting to house the sites and users. what I am having trouble with is how to tell the trigger who will be next in line on the list. 

Thanks for the help.