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
Samantha StarlingSamantha Starling 

Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, A workflow or approval field update caused an error when saving this record.

We are running into an error involving Person Accounts and can't figure out why. Any help would be appreciated.

ERROR.>

System.DmlException: ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, A workflow or approval field update caused an error when saving this record. Contact your administrator to resolve it. Record Type ID: value not valid for the entity: PersonAccount: []

TRIGGER>

/*
 * The TestPlatformAppsAfterLeadConversion test runs three Lead Conversion scenarios.  It tests Leads with no Platform
 * Apps attached via a Relate List, with one Platform App, and with two Platform Apps.  The Lead Conversion trigger
 * will add the ID of the newly created Account to any Platform Apps on the Lead.
 * 
 * [dug] 09.24.2015
 */
@isTest
public class TestPlatformAppsAfterLeadConversion {
    
    /*
     * The convertLeadWithNoPlatformApps test Lead Conversion with no associated Platform Apps 
     */
    static testMethod void convertLeadWithNoPlatformApps() {
        // Create a test Lead
        Lead newLead = new Lead();
        newLead.RecordTypeId = '012A0000000VmQk';
        newLead.FirstName = 'Pokit';
        newLead.LastName = 'Bot';
        newLead.Company = 'PokitDok';
        newLead.Status = 'MQL (Marketing Qualified)';  
        insert newLead;

        // Do the conversion
        Database.LeadConvert lc = new Database.LeadConvert();
        lc.setLeadId(newLead.id);

        // Run the test
        test.startTest();

        LeadStatus convertStatus = [Select Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        
        // Assert the conversion happened
        System.assert(lcr.isSuccess());

        test.stopTest();
    }