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
JAMBERT JESUDASANJAMBERT JESUDASAN 

round robin for task owner assignment

Hi,

I need to perform round robin logic for Task Creation. I have a queue "ABC" and it have 5 users. So If i create 9 tasks by bulk insert, 

user 1 - Task 1
User 2 - task 2 
User 3 - Task 3, 
User 4 - Task 4,
User 5 - Task 5,
User 1- Task 6,
User 2 - Task 7,
User 3- Task 8,
User 4 - Task 9.

I need the above logic needs to implement. and If I again insert 3 Task in Bulk Insert,
Now,
User 5 - Task 1,
User 1 - Task 2,
User 2 - Task 3

Thanks,
Jam
HARSHIL U PARIKHHARSHIL U PARIKH
You can follow the following steps,

1) Create a Task_Numbre__c field with data type of Auto Number on Task layout. Set the Auto Number Display Format to {0} (You can do this by going into - setUp- ActivityField)
2) Now, again on Task object create a Formula field named Round_Robin_ID__c with the formula returns number with 0 Decimal places.

MOD(VALUE(Task_Number__c), 5) + 1

Now, at this point whenever If you insert 10 tasks then it will have Round_Robin_ID__c as following,
Task Record -1, Round_Robin_ID__c = 1
Task Record -2, Round_Robin_ID__c = 2
Task Record -3, Round_Robin_ID__c = 3
Task Record -4, Round_Robin_ID__c = 4
Task Record -5, Round_Robin_ID__c = 5
Task Record -6, Round_Robin_ID__c = 1
Task Record -7, Round_Robin_ID__c = 2
Task Record -8, Round_Robin_ID__c = 3
Task Record -9, Round_Robin_ID__c = 4
Task Record -10, Round_Robin_ID__c = 5
Task Record -11, Round_Robin_ID__c = 1

I am sure you got the sequence!

3) Now, create a workflow rule Or Process builder which will do the following,
  Make Task Owner as User - 1 whenever Round_Robin_ID__c = 1
  Make Task Owner as User - 2 whenever Round_Robin_ID__c = 2
  Make Task Owner as User - 3 whenever Round_Robin_ID__c = 3
  Make Task Owner as User - 4 whenever Round_Robin_ID__c = 4
  Make Task Owner as User - 5 whenever Round_Robin_ID__c = 5

This wa all of yout task is equally distributed among all the users.
If you insert 20 tasks then all users would get 4 tasks each.
If you insert 200 tasks then all users would get 40 tasks each.

In addition, whenever you have more users added to the queue all you need to do is to change 5 to Number of users added. Same thing goes for whenever there is decrease in the number of users.
The only reason you need to create a workflow or process builder for assigning task to the certain owner is because there is no such a thing as TASK ASSIGNMENT rule in salesforce.

You can also follow this video link: https://www.youtube.com/watch?v=408po8mEGcM

Hope this helps!


 
JAMBERT JESUDASANJAMBERT JESUDASAN
Hi @Govind Guru, We need to create many workflows for to achieve this right? 
So, Do you have any idea about the apex code for owner assignment instead of Workflow and Process Builder? 

Thanks,
Jambert. 

 
edralphedralph