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

How to apply the - Round Robin Lead Assignment formula

I am a newbie, and want to know where are the steps to implement this formula. Is there a tutorial on how I can set this up. I am new to this software and would really appreciate any suggestions or help in this area.
* This is the formula is from the formula PDF *
- search round robin -
I have 4 sales pro's at the moment but will have 6-8 very soon. If that matters.
Best Answer chosen by Admin (Salesforce Developers) 
Is there a way to only apply the auto-number field to a certain Record Type?

All Answers

Did you ever get any assistance with your Round Robin question?
From the Salesforce Help pages:
Lead Numbering

This formula returns a number value for the text value in the auto-number field Lead Number. This can be useful if you want to use the Lead Number field in a calculation, such as round-robin or other routing purposes. Note that auto-number fields are text fields and must be converted to a number for numeric calculations.

VALUE( Lead_Number__c )

For details about using this function, see VALUE.

Round Robin Assignment of Cases or Leads

The following formula example for leads assumes you have three lead queues and you want to assign an equal number of incoming leads to each queue. You can also assign cases using a similar formula.

MOD(VALUE(Lead_Number__c) ,3)
This formula is for a custom formula field named Round_Robin_ID that assigns each lead a value of 0, 1, or 2. This formula uses a custom auto-number field called Lead Number that assigns each lead a sequential number starting with 1. The MOD function divides the lead number by the number of lead queues available (three in this example) and returns a remainder of 0, 1, or 2. Use the value of this formula field in your lead assignment rules to assign lead records to different queues. For example:
  • Round_Robin_ID = 0 is assigned to Queue A
  • Round_Robin_ID = 1 is assigned to Queue B
  • Round_Robin_ID = 2 is assigned to Queue C

For details about using these functions, see MOD and VALUE.

Saad Hameed
Senior Marketing & Sales Ops Manager

Hi there I am a new SF admin and I am trying to setup a lead assignment rule.
We have 3 sales reps and I would like to setup ROUND ROBIN lead distribution. We dont currently have any territory settings - I just want incoming leads to rotate between the 3 sales guys. I saw the post above however, I am not totally sure how to implement this. I dont want the leads to go into queues - I want them to go directly to the sales people.
I am hoping someone can help guide me through this.
Thanks :)

Just substitute the name of a salesperson instead of the queue name.  Queue is only an example of how it could be used.  Salesperson is fine, too.


Is there a way to only apply the auto-number field to a certain Record Type?
This was selected as the best answer
The Round Robin is great but I wonder how to incorporate case load balancing witht his as well. Anyone think of case load balancing to ensure it remains fair for all Support reps?

any answers to the last two replies?


I second what NIKAL asks.  We need case load balancing round robin routing rules.  I installed the round robin app but this is very limited and has some bugs (have to change owner twice.)  I'm acutally suprised SalesForce is not responding to this or providing any more functionality on round robin record assignment.  Seems this is an extremely common request.


Thanks Hameed. It was really great. Worked perfectly for me :)


"Is there a way to only apply the auto-number field to a certain Record Type?"


Does anyone know the answer? I need to apply round robin for certain type of leads.  I'd appreciate any suggestions.


I am not sure about this.


Create a number field.

Increment it by 1 using trigger( increment only if it is that record type). Something like following,


trigger xyz on UrObject(before insert) {

  Id rtId=[select Id from RecordType where name='Ur RecordType' and SObjectType='UrObject' limit 1].Id;

 for(UrObject ob: Trigger.New) {

  if(ob.RecordTpeId == rtId) {

  ob.numberField = ob.numberField + 1;





Please let me know whether this worked for you.






I came across a similar issue recently in which I had to assign records based on certain criteria.


This is the solution I came up with:


Hope this helps.



Thank You! But unfortunately I'm not familiar with APEX and Salesforce development at all. I was looking for a solution that involves only formula-fields, assignment rules etc. May be later i will have a chance to test your suggestion, I'll let you know if it works.


David Pier,


In your solution "AUTONUMBER" field - is it standard Salesforce auto-number field?

If so, it seems to me that this way of distribution doesn't work correct.

Let's examine the situation when every second created record of your custom object have "Small Product" product type. Autonumbers of these records will be 2,4,6,8,... Then "Small Assignment Number" of these records will allways be 0 (since you have 2 members in small product group) and all records will always go to the 1st user.


Please let me know if I misunderstood something.


Yes- it's a standard AutoNumber field.


The formula uses the AutoNumber field and assigns each record a sequential number starting with 1. The MOD function divides the number by the number of users and returns a remainder (starting with zero) into the custom field.


In my example, If I have two reps- each receiving the Small Product Type, I would set up the formula to be:




This will take the value in the AutoNumber field, divide it by two, and then return a remainder of 0 or 1.


So- if record X is assigned an AutoNumber of 1:

1/2 = .5

The intiger part is 0.

0 x 2 = 0

1-0 = 1.

1 is your remainder.


If record Y is assigned an AutoNumber of 88:

88/2 = 44

The intiger part is 44.

44 x 2 = 88

88-88 = 0.

0 is your remainder.


Since there are only two users in this group, all remainders will either be 0 or 1. You then set your workflow rules to assign records with a value of 0 to user 1 and records with a value of 1 to user 2


Yes, I got it. But I highly doubt that this will evenly distribute the records between users (and you want to distribute them evenly, correct?).


To illustrate my doubts I'll bring an example:


You have 100 Lead records created (suppose your object is Lead). 50 of them are of Small product, and 50 of them are of Big product. How do you know that 25 Small product leads would have even numbers in autonumber and the last 25 would have odd numbers?


If leads will be created in such order (this is extreme, but not impossible example):


1,3,5,...,99 - Big product type

2,4,6,...,100 - Small poduct type


then all your leads of Small product will have "0" as assignment number, and will go to the 1st user, while the 2nd user in this group will have 0 leads.


That's a very good point.


Yes- If every other record created has a critera of X and you are assigning records based on X, then they will all go to the same person.


However- I've never worked with an Org. where that is the case.


Since the number is assigned when the record is created- this assumes that there is no pattern to record creation. I've used this in two large Orgs now, and each has balanced very nicely. Sure- there may be one week where by chance there is some sort fo 'pattern' for a while, but it ends up taking care of itself :)

Ankit Tiwari 56Ankit Tiwari 56
Also, how can we assign the leads in round-robin when the stage value of a lead is changed or updated? I don't want the leads to be assigned on the initial stage but when the stage is changed? can this be done using flows or process builder?