Find the status code or exception name in your Salesforce error, such as REQUIRED_FIELD_MISSING or System.QueryException, then read its cause and fix. Paste the full message below to match it against 45 common errors, or browse the list by category.
Decode an error message
The search needs JavaScript. Every error below is listed in full and grouped by category, so you can browse or use Ctrl+F.
Paste an error message to find it in the reference.
How to read a Salesforce error
Most Salesforce errors have two parts: a code and a message. The code is a fixed name
such as UNABLE_TO_LOCK_ROW (an API status code) or System.NullPointerException (an Apex
exception). The message adds details, such as the field, the record ID or the text of your own validation rule. Look
up the code first.
API and DML errors use UPPER_SNAKE_CASE status codes. They appear in the UI, in API responses and
after first error: in an Apex System.DmlException.
Apex errors are exceptions named after their class, such as System.QueryException,
followed by a message and a stack trace with class, line and column.
Deployment errors come from the metadata API: compile errors, missing components and test or
coverage failures. They have no status code, so search for the message text.
Some errors are wrappers around the real cause. System.DmlException and
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY name the underlying error later in the text, after
first error: or caused by:. Find the inner error in the list below.
Where to see the full error
In Setup, open Debug Logs, add a trace flag for the affected user and reproduce the problem. In the log, search for
EXCEPTION_THROWN, FATAL_ERROR, VALIDATION_FAIL and CUMULATIVE_LIMIT_USAGE. From the CLI,
sf apex tail log streams logs while you test. For limit errors, see the
governor limits reference.
Errors by category
Data and DML12 errors. Errors when saving, deleting or referencing records.
Access and login5 errors. Permissions, sharing, sessions and credentials.
Typical message: FIELD_CUSTOM_VALIDATION_EXCEPTION, Amount must be positive: [Amount]
Cause
A validation rule on the object evaluated to true, so Salesforce blocked the save. The text after the code is the error message of that rule, and the field in brackets is where the rule shows the error.
How to fix
Read the message after the code: it is the rule's own error message.
In Setup, open Object Manager, the object, then Validation Rules, and find the rule with that message.
Fix the data so the rule passes, or correct the rule formula if it is wrong.
In Apex, catch DmlException and use getDmlMessage(0) to show the rule message to the user.
Typical message: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]
Cause
The record is missing a value for a field that is required by the platform (such as Name), by the field definition, or by the page layout used through the API call.
How to fix
Look at the field names in brackets and set a value for each one before the insert or update.
For a custom field, check whether the field itself is marked required in its definition.
In a data load, check the CSV column mapping and blank cells.
insert new Contact(FirstName = 'Ada'); // LastName is required
Typical message: DUPLICATES_DETECTED, Use one of these records?
Cause
An active duplicate rule with the Block action found a likely duplicate of the record you are saving. The Allow action with an alert can be overridden by the caller.
How to fix
Open the matching records named in the error and update one of them instead.
If the rule action is Allow with an alert, saving through Apex can set the duplicate rule header to allow the save.
Review the matching rule if it blocks legitimate records.
Database.DMLOptions dml = new Database.DMLOptions();
dml.DuplicateRuleHeader.allowSave = true;
Database.insert(acc, dml);
Typical message: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id
Cause
An ID in a lookup or master-detail field does not point to a usable record: it does not exist in this org, belongs to the wrong object, was deleted, or came from another org (for example a production ID used in a sandbox).
How to fix
Check that the ID exists in this org with a SOQL query on the target object.
Check the ID prefix matches the object the lookup expects.
After a data migration or sandbox refresh, remap IDs instead of copying them.
Typical message: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record
Cause
Two transactions tried to update the same or related records at once, so one timed out waiting for the lock, or they deadlocked. Roll-up summary fields and child records of the same parent are common causes because the parent is locked.
How to fix
Retry the failed operation; the error is often transient.
In bulk loads, lower the batch size or switch to serial processing, and sort records by parent so batches do not compete for the same parent.
Avoid running many jobs against the same parent record at the same time.
In Apex, SOQL FOR UPDATE locks records on purpose; keep the transaction short.
Typical message: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id
Cause
The running user lacks the permission or record access needed for the action, for example edit or delete rights on that record through ownership, sharing or object permissions.
How to fix
Check object permissions (create, read, edit, delete) for the user in their profile and permission sets.
Check record access: the owner, role hierarchy, sharing rules and org-wide defaults for the object.
Reproduce as the user: use Login As in a sandbox or run the Apex in a System.runAs test.
Typical message: INVALID_FIELD: No such column 'Foo__c' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name.
Cause
The query names a field that does not exist on the object, is misspelled, lacks the __c suffix, or is not visible to the running user.
How to fix
Check the field API name on the object in Object Manager (labels differ from API names).
Custom fields end with __c, and relationship paths use __r.
Check that the user has field-level security access to the field.
If the field is in a package, include the namespace prefix.
SELECT Id, Region__c FROM Account // field must be Region__c, not Region
Typical message: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Cause
A query in a trigger filters on fields that are not selective on an object with a large number of records, so Salesforce refuses to run it.
How to fix
Add a filter on an indexed field that narrows the results to a small share of records.
Avoid filtering on formula fields or fields with mostly the same value.
Ask Salesforce Support about a custom index when the filter is correct but still not selective.
Typical message: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]
Cause
A DML statement failed. This is a wrapper: the real reason is the status code after "first error:".
How to fix
Find the status code after "first error:" and look it up in this list.
The row number is zero-based: row 0 is the first record in the list.
Use Database.insert(records, false) and inspect each SaveResult to see every failure instead of only the first.
Database.SaveResult[] res = Database.insert(records, false);
for (Database.SaveResult r : res) {
if (!r.isSuccess()) System.debug(r.getErrors()[0].getStatusCode() + ': ' + r.getErrors()[0].getMessage());
}
Typical message: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa)
Cause
One transaction changed both a setup object (such as User, Group or PermissionSetAssignment) and a non-setup object (such as Account). Salesforce limits this mix.
How to fix
Move one of the DML operations to a separate transaction, such as a Queueable or @future method.
In tests, wrap the setup-object DML in System.runAs(user) { ... }.
Typical message: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001...) is currently in trigger X, therefore it cannot recursively update itself
Cause
A trigger updated or deleted the same record it is running for, in a way that is not allowed, such as updating the record from its own before trigger by DML.
How to fix
In a before trigger, set field values on Trigger.new directly instead of using DML.
Do not delete the triggering record from its own trigger.
Use a static flag to guard against recursion if two triggers update each other.
Typical message: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MyTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object
Cause
An error occurred in a trigger, flow or process that ran while saving. This is a wrapper: the real error is the exception named after "caused by". The status code can also mean a missing permission to create, update or activate the record.
How to fix
Read the text after "caused by:" and find that exception in this list.
The trigger name and line number in the message show where it failed.
Reproduce with the same data and open the debug log to see the execution path.
Typical message: Variable does not exist: Region__c
Cause
An Apex compile error: the code uses a variable or field that does not exist in the org, is misspelled, or is not visible to the code (for example a field missing in the target org).
How to fix
Check the spelling and the API name of the field or variable.
If it is a custom field, confirm it exists in the org you are saving or deploying to.
When deploying, include the field in the deployment or deploy it first.
An OAuth token request was refused. Common reasons: wrong username, password or token, a user the connected app does not allow, an expired or revoked refresh token, or a login URL that does not match the org (production versus sandbox or My Domain).
How to fix
Check the token endpoint host matches the org type (login.salesforce.com, test.salesforce.com or your My Domain).
Check the connected app policies: permitted users and pre-authorized profiles or permission sets.
For JWT bearer flow, check the username, the certificate and that the app is pre-authorized for that user.
Request a new refresh token if the old one was revoked.
Typical message: System.LimitException: Apex CPU time limit exceeded
Cause
Apex code, triggers, flows and other automation in the transaction used more CPU time than allowed. Nested loops, heavy string work and many automations on one record are common causes.
How to fix
Use the debug log with limits and profiling to find the slow code.
Replace nested loops over lists with Maps.
Move long work to Queueable or Batch Apex.
Check for many triggers, flows and process automation firing on the same object.
Typical message: In field: object - no CustomObject named Invoice__c found
Cause
A component in the deployment (a layout, permission set, profile, flow or field) refers to an object that is neither in the target org nor part of this deployment. The same message pattern applies to other types, such as "no CustomField named ...".
How to fix
Add the missing object or field to the package.xml or deploy source so it ships in the same deployment.
Check the object API name spelling and the namespace prefix.
If the component should not reference it, remove the reference from the metadata file.
Typical message: Dependent class is invalid and needs recompilation: Class MyClass : Variable does not exist: Region__c
Cause
An Apex class that the deployed code depends on no longer compiles, often because a field or class it uses was changed, removed or is missing in the target org.
How to fix
Read the text after the second colon: it is the actual compile error in the dependent class.
Deploy the missing or changed fields and classes together with the code.
Recompile all classes in Setup after fixing the cause.
Frequently asked questions
What is the difference between an error code and an error message in Salesforce?
The code is a fixed identifier such as REQUIRED_FIELD_MISSING or System.NullPointerException that says what kind of failure happened. The message is human-readable text that can include field names, IDs or your own validation rule text. Search for the code first, then use the message to find the field or record.
What does "first error" mean in a System.DmlException?
System.DmlException is a wrapper. The text after "first error:" is the real status code and message for the first failing record, and "row 0" is the first record in the list because rows are counted from zero. Using Database.insert with allOrNone set to false lets you read the error of every record.
Why does CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY appear with another exception after "caused by"?
It wraps an error raised by a trigger, flow or process that ran while the record was being saved. The exception after "caused by" is the real problem, and the trigger name and line number show where it happened. Without a "caused by" part, the code can also mean you lack permission to create, update or activate the record.
How do I see the full error for an Apex or automation failure?
Open Debug Logs in Setup, add a trace flag for the user, reproduce the problem and open the log. Search it for EXCEPTION_THROWN, FATAL_ERROR, VALIDATION_FAIL and CUMULATIVE_LIMIT_USAGE. In VS Code or the CLI you can also tail logs with sf apex tail log.
Is this list complete?
No. Salesforce documents hundreds of status codes, and this page covers 45 of the most common errors with advice written by SFDX Talk. For a code that is not listed, check the StatusCode list in the SOAP API Developer Guide, which is linked as the source.
Does the decoder send my error message anywhere?
No. Matching runs in your browser and the text you paste is not sent to SFDX Talk or anyone else. Still, remove record IDs, names and other customer data from errors before you share them with others.
DevOps: Scan Apex, LWC, JavaScript, and Flow code for security vulnerabilities, quality issues, and AppExchange compliance with Salesforce Code Analyzer.
SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Salesforce changes its platform every release, so confirm against the
official page before relying on a value.