You need to sign in to do that
Don't have an account?
Myra Wilson 9
Need to incorporate record type into code for round robin
I am trying to create a round robin assignment on contacts in my org. I found code online but I need to add a line for the code to trigger upon the change of the record type and I am unsure how to do that.
trigger contacttrigger on Contact (before insert) {
if(Trigger.isBefore){
Double roundRobinValue = 1;
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){
roundRobinValue = conList[0].Round_Robin_ID__c;
}
for(Contact c : Trigger.New){
system.debug('###Round Robin Value : '+roundRobinValue);
if(roundRobinValue == 18){
roundRobinValue = 1;
c.OwnerId = '0057F000002FrWT';
}
else if(roundRobinValue == 2){
roundRobinValue++;
c.OwnerId = '0057F000005vkd1';
}
else if(roundRobinValue == 3){
roundRobinValue++;
c.OwnerId = '0057F000005vkd1';
trigger contacttrigger on Contact (before insert) {
if(Trigger.isBefore){
Double roundRobinValue = 1;
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){
roundRobinValue = conList[0].Round_Robin_ID__c;
}
for(Contact c : Trigger.New){
system.debug('###Round Robin Value : '+roundRobinValue);
if(roundRobinValue == 18){
roundRobinValue = 1;
c.OwnerId = '0057F000002FrWT';
}
else if(roundRobinValue == 2){
roundRobinValue++;
c.OwnerId = '0057F000005vkd1';
}
else if(roundRobinValue == 3){
roundRobinValue++;
c.OwnerId = '0057F000005vkd1';
Also will need to add RecordTypeId column in SOQL