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.
This article explains how to resolve the CANNOT_UPDATE_CONVERTED_LEAD error in an Apex Trigger by filtering out converted Lead records before performing DML operations.
Once a Lead is converted, only the convertedAccountId or convertedContactId fields can be referenced on that Lead record. Any attempt to update other fields via an Apex Trigger will result in the CANNOT_UPDATE_CONVERTED_LEAD error.
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:
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
}
}
By checking IsConverted before executing DML operations, the Apex Trigger only processes Lead records that have not yet been converted, which prevents the CANNOT_UPDATE_CONVERTED_LEAD error from being thrown.
000384333

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.