How to Create Manual Round Robin ID in Salesforce


In this blog you will learn to create a Manual Round Robin ID using custom Apex in Salesforce. The requirement was to create a Round Robin ID for Converted Lead with a particular status. I have implemented the functionality using some custom Apex and a process builder. In this video I will share my experience and work around for this strange requirement. #RoundRobinID #Salesforce

I will share my Apex in this blog, for complete configuration you can checkout my vlog below :

Apex
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
public class UpdateConvertedContact {
	@InvocableMethod
    public static void updateContact(List<String> contactIds){
        Double roundRobinValue = 1;
        Contact con=[SELECT Id, Round_Robin_ID__c FROM Contact where Id in:contactIds];
        List<Contact> conList = [SELECT Id, Round_Robin_ID__c, CreatedDate FROM Contact where Round_Robin_ID__c != null
                                 order by CreatedDate desc limit 1];
        if(conList != null && conList.size()>0){
            if(conList[0].Round_Robin_ID__c != 2){
                roundRobinValue = conList[0].Round_Robin_ID__c +1;
            }
            else{
                roundRobinValue = 1;
            }
        }
        con.Round_Robin_ID__c = roundRobinValue;
        update con;
    }
}

Checkout the vlog below


If you have any question please leave a comment below.
If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !

Thanks
Keep Coding 

Post a Comment

0 Comments