Skip to main content
4 of 4
added 10 characters in body
Ratan Paul
  • 22.8k
  • 14
  • 55
  • 99

showing error System.NullPointerException: Attempt to de-reference a null object

class...

public class ExceptionCreateExceptionRecord{
public static void insertException(Map<string, string> param)
    {    
    Exception__c newExcept              =   new Exception__c();
        newExcept.ExceptionTypeCode__c      =   param.get('ExceptionTypeCode__c');
        newExcept.RecordType.DeveloperName  =   'New Exception'; 
        
        
test class

    @isTest(SeeAllData=true)
    public class TestExceptionCreateExceptionRecord {
       static testmethod void Exception(){
        map<String ,String> parm=new map<String,String>();
            parm.put('ExceptionTypeCode__c', 'open');                
            parm.put('entry2','Second entry'); 
       ExceptionCreateExceptionRecord excep=new ExceptionCreateExceptionRecord();   
        ExceptionCreateExceptionRecord.insertException(Parm);
        
    

stacktrace

Class.ExceptionCreateExceptionRecord.insertException: line 7, column 1( newExcept.RecordType.DeveloperName = 'New Exception'; ) Class.TestExceptionCreateExceptionRecord.Exception: line 8, column 1( ExceptionCreateExceptionRecord.insertException(Parm);)