You need to sign in to do that
Don't have an account?
Rahul Maila 5
Don't know whats going wrong in this Code:
public class CaseAutoNumberHandler {
public static void updateCounterSurvey(List<Case> cases){
Integer maxLead_SSR;
List<case> cases_SSR = [SELECT Id, CaseNumber, SSR_AutoNumber__c FROM Case Where and CreatedDate = this_year order by createdDate desc limit 1];
if(cases_SSR !=null && cases_SSR.size() == 0){
system.debug('X - SelfService Size ' + cases_SSR.size() );
maxLead_SSR = 0;
}else{
maxLead_SSR = Integer.valueOf(cases_SSR[0].SSR_AutoNumber__c);
}
for(Case caseList:cases){
if(caseList.RecordTypeId =='012200000002Ny1' && caseList.Region__c == 'UK & IReland'){
caseList.SSR_AutoNumber__c = ++maxlead_SSR;
}
}
}
}
This code is to generate autonumber for a specific recordtype.
Two things:
1. In the SOQL, in the where clause when I put "CreatedDate != this_year" and go back to create a case to see if AutoNumber is being genetrated fine I get 'System.Query.Exception: Non-selective Quesry against large Object Type'.
2. Then when I come back and change the where clause to "CreatedDate = this_year", case gets created but AutoNumber stays at the same value like it was for pervious case. Dont understand what I am doing wrong. Any pointers would be much Appricriated!
public static void updateCounterSurvey(List<Case> cases){
Integer maxLead_SSR;
List<case> cases_SSR = [SELECT Id, CaseNumber, SSR_AutoNumber__c FROM Case Where and CreatedDate = this_year order by createdDate desc limit 1];
if(cases_SSR !=null && cases_SSR.size() == 0){
system.debug('X - SelfService Size ' + cases_SSR.size() );
maxLead_SSR = 0;
}else{
maxLead_SSR = Integer.valueOf(cases_SSR[0].SSR_AutoNumber__c);
}
for(Case caseList:cases){
if(caseList.RecordTypeId =='012200000002Ny1' && caseList.Region__c == 'UK & IReland'){
caseList.SSR_AutoNumber__c = ++maxlead_SSR;
}
}
}
}
This code is to generate autonumber for a specific recordtype.
Two things:
1. In the SOQL, in the where clause when I put "CreatedDate != this_year" and go back to create a case to see if AutoNumber is being genetrated fine I get 'System.Query.Exception: Non-selective Quesry against large Object Type'.
2. Then when I come back and change the where clause to "CreatedDate = this_year", case gets created but AutoNumber stays at the same value like it was for pervious case. Dont understand what I am doing wrong. Any pointers would be much Appricriated!
Let us know if this will help you