+ Start a Discussion


i executed my DML query class it is giving me error for the following code

       Account acc= new Account(LastName='ABC',RecordTypeId=RecTypes__c.getInstance('AccountClient').Record_Type_Value__c);

the error that i am geting is as follows


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

Class.DatabaseDMLTest.myUnitTest7: line 94, column 91 External entry point




can i get y am i getting this error in test class for DML query

Rahul S.ax961Rahul S.ax961

Thats due to,

there's is no value in RecTypes__c.getInstance('AccountClient').Record_Type_Value__c.

Instead use a query like:

Account acc= new Account(Name='ABC',RecordTypeId=[Select Id from RecordType where name = 'AccountClient'].Id);


i just tried to display the ID using the query that you posted but its not giving me any output.