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
DeptonDepton 

test class specify account record type

I do have a test class, when I run the test i got this error:

 

 

System.DmlException: ConvertLead failed. First exception on row 0; first error: UNAVAILABLE_RECORDTYPE_EXCEPTION, Unable to find default record type: []Class.TestTriggerAreaUpdate.TestReferralUpdate: line 20, column 38 External entry point

 

 

How do I specify the Account record type in the TestClass?....or i missed it in the trigger.....is a person account (just in case that helps)

Thank you

 

 

@isTest
//This is a test case for a situation where a lead will be converted.  The developer must explicitly call the convert lead
//method to simulate the user action.

private class TestTriggerAreaUpdate {
        static testMethod void TestReferralUpdate() {
        // Insert the Lead
        List<Lead> leads = new List<Lead>();
        Lead leadt = new Lead (FirstName ='fname', LastName ='test', Company ='myCompany');
        insert leadt;
        // Insert the custom object Record 
        reas_de_Inter_s__c Area = new reas_de_Inter_s__c (Lead__c = leadt.Id);
        insert Area;    
    
    //Convert the Lead
    Database.LeadConvert lc = new database.LeadConvert();
    lc.setLeadId(leadt.Id);
    LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
    lc.setConvertedStatus(convertStatus.MasterLabel);
    Database.LeadConvertResult lcr = Database.convertLead(lc);    
    
    //Requery for the referral record to see if it is updated
    reas_de_Inter_s__c ref_upd = [select Account__c from reas_de_Inter_s__c where Lead__c = :leadt.Id];
        
    //Check that the test passed
        System.assertEquals(ref_upd.Account__c,[Select ConvertedAccountId From Lead Where Id = :Area.Lead__c].ConvertedAccountId);
              
  
    //Test if no opty is created
    string NoOpty = 'Y';    
    if (NoOpty =='Y'){
      Lead leadto = new Lead (FirstName ='fnameo', LastName ='testo', Company ='myCompanyo');
          insert leadto;
          // Insert the custom object record 
          reas_de_Inter_s__c Areao = new reas_de_Inter_s__c (Lead__c = leadto.Id);
          insert Areao;
      
      Database.LeadConvert lco = new database.LeadConvert();
      lco.setLeadId(leadto.Id);
      lco.isDoNotCreateOpportunity();
      lco.setDoNotCreateOpportunity(true);
      LeadStatus convertStatuso = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
      lco.setConvertedStatus(convertStatuso.MasterLabel);
      Database.LeadConvertResult lcro = Database.convertLead(lco); 
    
      reas_de_Inter_s__c ref_updo = [select Account__c from reas_de_Inter_s__c where Lead__c = :leadto.Id];
      
      //Check that the test passed
          System.assertEquals(ref_updo.Account__c,[Select ConvertedAccountId From Lead Where Id = :Areao.Lead__c].ConvertedAccountId);
 
    }  
    }

 

chechecheche

hi depton, force newbie here. XD

 

i'm encountering this error now, have you figured why is this happening?

 

thanks!