Round Robin Assignment Using Trigger and WorkFlow Rule

In this tutorial, we will learn how to assign cases using RRD for example purpose.

Step 1 – Round Robin Assignment using Workflow Rule: – Use WorkFlow rule for RRD whenever you know the number of users you need to distribute LEAD/CASE for example 3, 4, 5 users. For limited users, Salesforce has already published an article and you can give it a try here How do I create a round-robin assignment for Leads or Cases to users?

But in most of the cases, we do not know how many users and queues will be involved to which we want to distribute the CASE?LEAD to this scenario I have written a custom solution read step 2.

Step 2:- Round Robin Assignment using Triggers: –  If you do not aware that how many users will be there in the queue then you need to write a custom logic using the trigger.

Prerequisites: –

  • Basic Understanding of Apex
  • Basic Understanding of Workflow Rule
  • Basic Understanding of Queues.

1- Create a Queue and add users to that queue. Setup -> Administer -> Manage Users -> Queues -> New and enter Label, Queue Name, Select Object for example Case and Select users that you wanted to Add.

2 – Create a Workflow rule:- In this step, we will create a WFR which will update the case owner to the Queue that we have created. Setup -> Create Workflow & Approval Process -> Workflow Rules -> New Rule -> Case -> see screenshot below. (You can also create the same workflow into LEAD object case is used for an example).

Queue

For Workflow Action Select New Field Update and change the Owner to the Queue that we have created earlier. Click on Save and then Click on Done and activate the workflow.

Final picture of workflow will look like below

Complete Workflow

3 – Create a new custom autonumber field into Case/Lead Object. Setup -> Customize -> Cases -> fields -> scroll down to “Case Custom Fields & Relationships” section and click on new button. Data Type Select AutoNumber Click next Enter field Label like Case # and display format(Case-{0000}), starting number(1) and check “Generate Auto Number for existing records” checkbox if you want to generate auto number for existing case/leads other wise leave it blank. Next, Next and do not add this field into Layout and Click on Save.

CustomField

4- Create Apex class and Apex Trigger:-  Here we are, we are done with configuration part and in this step we will create a trigger and it’s handler class which be responsible for assigning the cases/leads using Round Robin Algo.

  • Setup -> Develop -> Apex Classes -> New -> and Go to THIS CLASS and paste the code here
  • Setup -> Customize -> Cases -> Case Triggers -> and paste the code provided HERE.

 

Now in the final step test the functionality by creating multiple cases and cases will be assigned to those users that are available into queues using Round Robin Algo.

Hope this blog was helpful to you. You can also get the complete document Here.

 

6 thoughts on “Round Robin Assignment Using Trigger and WorkFlow Rule

  1. Nishant September 24, 2019 / 10:52 am

    Is there any way to avoid using workflows ?

    Like

  2. Mirketa July 23, 2019 / 8:35 am

    Round Robin Distributor (RRD)-
    Automate your Leads, cases distribution, and allocation to your team members and reduce the workload of your managers so that they can focus on more important tasks.
    With our top rated product Round Robin Distributor (RRD), we help organizations achieve the best in the industry efficiency for resolving customer cases by assigning the right case to the right team member. RRD is fully customizable as per your business needs. Download and try the latest version for FREE now- https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3000000DpgwTEAR

    Like

  3. Deshpande July 30, 2018 / 11:14 am

    Can we create it for custom object like project?

    Like

    • Amit Singh July 31, 2018 / 11:03 am

      Yes. We can do the same for the Custom Object. Follow the same process for the custom object.

      Like

  4. Read more about Vyakar’s Lead Router December 28, 2017 / 12:20 pm

    Your article was very helpful in understanding the topic lead assignment. I enjoyed while reading your post. Thank you for sharing this valuable information.

    Like

    • Amit Singh December 28, 2017 / 3:04 pm

      Glad to hear that it helps you.

      Please share it with your friends.

      Like

Leave a comment