“We have hundreds of leads per day coming in via webform and purchased lists which are then assigned out by a single individual to a team of 15. This can take hours.”
This is one of the challenges a higher education customer presented to us, one which has been voiced by many businesses. At ThirdEye, we have leveraged Salesforce Flow to automate this process, creating, in effect, a round-robin process. This process can be easily tweaked to:
- Change the object of the record which is being assigned
- Create a subset of users (the assignment pool) as based on certain characteristics
- Optimise the process based on the number of users
- Add logic to select a different subset of users based on attributes of the record being assigned
The Basics
The process consists of a Launcher Flow and an Assignment Engine.
Launcher Flow
The Launcher Flow has one input variable, which is the ID of the record which needs to be assigned. The first component we will insert is a ‘Get Records’ component, which is used to store the pool of users we want to be in the assignment round robin.
For this specific example, the only filter we are using in our query is ‘IsActive = True’, but clients have had additional filters such as ‘Team__c = Team 1’. This will return an ‘sObject’ collection with all the users who will be candidate assignees. We can add a decision point to check whether any users were found.
The second step in our Launcher takes us into the actual Assignment Engine.
We are passing in the ‘sObject’ collection of our assignment pool as well as the ID of the record which needs to be assigned. The output of this is the ID of the assigned owner of the record.
The last part of the Launcher is the record update.
We are using the lead object, but any custom object which is not the detail of a Master-Detail relationship can be used, and this is the only component of the flow which needs to be changed to use a different object.
The Assignment Engine
Now for the best part. To randomise the process as much as possible, we will use the ID of the record we are about to assign. We will convert, starting from the left-most character, the letters of the ID into numbers.
This will give us a number from 0-9, which will work well if the assignment pool consists of 10 users or less. If we have between 11 and 99 users, we can also leverage the penultimate character in the record ID.
Now that we have two digits from 0-9, we can use a formula to concatenate them into a single number.
VALUE(TEXT({!for_character2}) & TEXT({!for_character1}))
So if our record ID is ‘00Q3z00001D4D0gEAF’, our randomly generated number will be 15. We will now assign this to our variable, ‘var_RandomNumber’. We will now use this variable in a formula that will be used as a baseline for identifying whether the record is ready to be assigned or not.
IF({!var_LoopNumber}>9,
VALUE(RIGHT(TEXT({!for_RandomNumber}),2)),
VALUE(RIGHT(TEXT({!for_RandomNumber}),1)))
This is to ensure that we are using the correct number of digits from our randomly generated number (00 is not equal to 0).
The next step in the Assignment Engine is the loop. We will loop through each user from our assignment pool and decide whether we will assign the record to this user or not, and we can achieve this by counting the number of loops we go through, starting with 0.
So if the last two digits of the ID are ‘Ao’, the formula will return 15. When we reach loop number 15, whoever that user is will become the owner of the record. In this specific example, should we have only 13 users in our assignment pool, we will exit the loop, pass through the re-enter loop element and restart the list of users. We will go through the loop two more times and then assign the lead.
Once this decision outcome has been reached, we will exit the Assignment Engine and return to the Launcher. Here, the record will be updated with the new owner and the process will be over.
Launching the Flow
To automate this process, we are leveraging the Mass Action Scheduler, which gives us the flexibility to determine the subset of leads we want to enter into the process and the frequency with which the process takes place.
Enhancements
This flow can be enhanced to leverage attribute-based assignment as well. By adding in new elements we can add further complexity. Ensure you have contingency in place in case certain records are not found.