You need to sign in to do that
Don't have an account?
Shashank Somwanshi
Compile Error: Variable does not exist name
public class HSE_CaseTriggerHandler {
public static void handleBeforeinsert(list<Case> newCases){
List<Escalation_Matrix__c> compareValueobj = new List<Escalation_Matrix__c>();
compareValueobj = [Select id, Reason__c, Severity__c, Sub_Reason__c from Escalation_Matrix__c Limit 5000];
Map<String,Id> mapOfEscalationMatrix = new Map<String,Id>();
For(Escalation_Matrix__c em : [Select id, Reason__c, Severity__c, Sub_Reason__c from Escalation_Matrix__c Limit 5000])
{
mapOfEscalationMatrix.put(em.Reason__c+'-'+em.Severity__c+'-'+em.Sub_Reason__c ,em.id);
}
Set<id> setofintent = new Set<id>();
for(Case c: newCases)
{
if(c.Case_Reason_Intent__c!=NULL)
setofintent.add(c.Case_Reason_Intent__c);
}
//Lookup on case reason intent to get the name
Map<Id,String> mapOfIntent = new Map<Id,String>();
For(Case_Reason_Intent__c cri : [Select id,name from Case_Reason_Intent__c where id in : setofintent])
{
mapOfIntent.put(cri.id, cri.name);
}
Map<Id,String> mapOfIntentAll = new Map<Id,String>();
For(Case_Reason_Intent__c cri : [Select id,name from Case_Reason_Intent__c])
{
mapOfIntentAll.put(cri.id, cri.name);
}
for(Case cs: newCases){
if(cs.Subject !=NULL && cs.Case_Reason_Intent__c ==NULL && mapOfIntentAll.containskey(cs.name) == cs.Subject){
cs.Case_Reason_Intent__c = mapOfIntent.get(cs.Name);
system.debug(cs.Case_Reason_Intent__c);
}
}
for(Case c: newCases){
if(c.status!='Closed' && !c.IsEscalated && c.status!=NULL && c.Case_Reason_Intent__c!=NULL && c.Sub_Reason__c !=NULL && c.Severity__c!=NULL && mapOfIntent.containskey(c.Case_Reason_Intent__c) && mapOfEscalationMatrix.containskey(mapOfIntent.get(c.Case_Reason_Intent__c)+'-'+c.Severity__c))
{
c.Escalation_Matrix__c = mapOfEscalationMatrix.get(mapOfIntent.get(c.Case_Reason_Intent__c)+'-'+c.Severity__c);
}
}
}
}
public static void handleBeforeinsert(list<Case> newCases){
List<Escalation_Matrix__c> compareValueobj = new List<Escalation_Matrix__c>();
compareValueobj = [Select id, Reason__c, Severity__c, Sub_Reason__c from Escalation_Matrix__c Limit 5000];
Map<String,Id> mapOfEscalationMatrix = new Map<String,Id>();
For(Escalation_Matrix__c em : [Select id, Reason__c, Severity__c, Sub_Reason__c from Escalation_Matrix__c Limit 5000])
{
mapOfEscalationMatrix.put(em.Reason__c+'-'+em.Severity__c+'-'+em.Sub_Reason__c ,em.id);
}
Set<id> setofintent = new Set<id>();
for(Case c: newCases)
{
if(c.Case_Reason_Intent__c!=NULL)
setofintent.add(c.Case_Reason_Intent__c);
}
//Lookup on case reason intent to get the name
Map<Id,String> mapOfIntent = new Map<Id,String>();
For(Case_Reason_Intent__c cri : [Select id,name from Case_Reason_Intent__c where id in : setofintent])
{
mapOfIntent.put(cri.id, cri.name);
}
Map<Id,String> mapOfIntentAll = new Map<Id,String>();
For(Case_Reason_Intent__c cri : [Select id,name from Case_Reason_Intent__c])
{
mapOfIntentAll.put(cri.id, cri.name);
}
for(Case cs: newCases){
if(cs.Subject !=NULL && cs.Case_Reason_Intent__c ==NULL && mapOfIntentAll.containskey(cs.name) == cs.Subject){
cs.Case_Reason_Intent__c = mapOfIntent.get(cs.Name);
system.debug(cs.Case_Reason_Intent__c);
}
}
for(Case c: newCases){
if(c.status!='Closed' && !c.IsEscalated && c.status!=NULL && c.Case_Reason_Intent__c!=NULL && c.Sub_Reason__c !=NULL && c.Severity__c!=NULL && mapOfIntent.containskey(c.Case_Reason_Intent__c) && mapOfEscalationMatrix.containskey(mapOfIntent.get(c.Case_Reason_Intent__c)+'-'+c.Severity__c))
{
c.Escalation_Matrix__c = mapOfEscalationMatrix.get(mapOfIntent.get(c.Case_Reason_Intent__c)+'-'+c.Severity__c);
}
}
}
}
Case object do not have field Name(, equivalent field is CaseNumber).
Error should be due to this :
for(Case cs: newCases){
if(cs.Subject !=NULL && cs.Case_Reason_Intent__c ==NULL && mapOfIntentAll.containskey(cs.name) == cs.Subject){
cs.Case_Reason_Intent__c = mapOfIntent.get(cs.Name); //ERROR line : cs.Name do not exist
system.debug(cs.Case_Reason_Intent__c);
}
}
Thanks