Loading

Error 'CANNOT_UPDATE_CONVERTED_LEAD' When Executing Apex Trigger on Lead Record

Udgivelsesdato: Oct 9, 2026
Beskrivelse

When an Apex Trigger runs on the Lead object in Salesforce, the following error may be thrown:

Error Message: CANNOT_UPDATE_CONVERTED_LEAD

This error occurs specifically when the trigger logic attempts to modify or update a Lead record that has already been converted, or when it tries to reference the Lead's record ID after conversion has taken place.

In Salesforce, Lead conversion is the process of converting a qualified Lead into an Account, Contact, and optionally an Opportunity. Once a Lead is converted, Salesforce treats the Lead record as read-only for most field updates. Any Apex Trigger logic that attempts to perform a DML update on a converted Lead will throw this error.

A common scenario where this occurs is an after-update or after-insert Apex Trigger on the Lead object that does not check whether the Lead is already converted before attempting further DML operations.

Løsning

This article explains how to resolve the CANNOT_UPDATE_CONVERTED_LEAD error in a Salesforce Apex Trigger on the Lead object by filtering out converted Lead records before performing DML operations.

Why the CANNOT_UPDATE_CONVERTED_LEAD Error Occurs

Once a Lead is converted, only the convertedAccountId or convertedContactId fields can be referenced on that Lead record. Any attempt to update other fields from an Apex Trigger results in the CANNOT_UPDATE_CONVERTED_LEAD error.

How to Exclude Converted Leads in an Apex Trigger

To prevent this error, update the Apex Trigger logic to exclude converted Lead records before performing any DML operations. Use the IsConverted field on the Lead object to filter out converted records.

The following example shows how to add this check in an Apex Trigger. The code loops through the Leads in Trigger.new, adds only the Leads where IsConverted is false to a list, and runs the trigger logic only if that list is not empty.

`trigger LeadTrigger on Lead (before update, after update) {
    List<Lead> unconvertedLeads = new List<Lead>();

    for (Lead l : Trigger.new) {
        if (!l.IsConverted) {
            unconvertedLeads.add(l);
        }
    }

    // Perform DML operations only on unconverted Leads
    if (!unconvertedLeads.isEmpty()) {
        // Add your trigger logic here
    }
}`

Result of Checking IsConverted

By checking IsConverted before executing DML operations, the Apex Trigger processes only Lead records that have not yet been converted, which prevents the CANNOT_UPDATE_CONVERTED_LEAD error from being thrown.

Vidensartikelnummer

000384333

 
Indlæser
Salesforce Help | Article