Next Tutorial: Using Spigot Stamps To Audit Spigot Actions
๐ Goal: Round Robin Lead Distribution with Spigots
๐ฏ Objective
- Move leads from a staging user (
User User) to two other Users (Test UserandSecurity User) in round robin fashion. - Leads being moved must:
- Be owned by
User User - Have a status of Open – Not Contacted
- Be owned by
- Ensure fair distribution over time.
๐๏ธ Implementation Steps
- Create New Spigot:
- Name:
Lead Assignment - App Configuration: Primary App Configuration
- Run Order:
50(between 0 and 100) - Schedule:
Always Running
- Name:
- Set Input Records:
- From
Leads - Where:
Owner = 'User User‘Status = 'Open - Not Contacted‘
- Ordered by:
CreatedDate DESC - Limit:
3(to show uneven split behavior)
- From
- Add Modifier (Set of User Records):
- From:
User - Where:
- Is
Active = trueANDDivision = 'Sales‘ - OrderBy:
ID ASC(for consistent assignment order) - Limit:
2000(future-proofing for team growth)
- Is
- From:
- Create Spigot Action:
- Name:
Round Robin Distribute Leads to Users - Type:
SObject - Subtype:
Update - Action:
- Update the Lead Owner ID
- Set
OwnerId = Mod1.Id(Mod1 is the set of Sales User Records)
- Name:
๐ Expected Behavior
- On first run (with 3 leads):
Test Usergets assigned 2 leadsSecurity Usergets assigned 1 lead
- On next run (with 3 new leads):
Test Usergets assigned 1 lead (now has 3)Security Usergets assigned 2 leads (now has 3)
- Continues alternating to even out total assignments over time.
๐ก Key Insights
- Round robin works by cycling through the modifier list (users).
- The ordering of modifiers (users) matters โ hence sorting by ID.
- The setup is abstract and reusable:
- Could be used to set any field on any object based on similar inputs, modifiers, and actions.
- Not limited to Leads or Owner asssignment
๐ Results Observed
- Leads correctly assigned to new users based on create date.
- Fair, even distribution over multiple runs.
- The system keeps track of state and rotates through users consistently.
Leave a Reply