function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shashank SomwanshiShashank 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);
            }   
        }  
        
        
    }      
               
}
Vishwajeet kumarVishwajeet kumar
Hello,
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