INVALID_FIELD_FOR_INSERT_UPDATE: field is not writable
What does this error mean?
This error occurs when an Apex script, API request, or data import attempts to insert or update a field that cannot be modified.
Certain fields in Salesforce are read-only or automatically managed by the system, so they cannot be set directly during DML operations.
Common Causes
1. Attempting to update read-only fields
Fields like CreatedDate, LastModifiedDate, and SystemModstamp are system-managed.
2. Updating formula fields
Formula fields calculate values automatically and cannot be written to.
3. Updating auto-number fields
Auto-number fields are generated by Salesforce and cannot be set manually.
4. Field-level security restrictions
The running user may not have permission to edit the field.
How to Fix It
Solution 1 — Remove read-only fields from DML
Account acc = new Account();
acc.Name = 'Test Account';
insert acc;
Solution 2 — Check field permissions
Ensure the running user has edit access to the field.
Setup → Object Manager → Fields & Relationships → Field-Level Security
Solution 3 — Avoid updating formula fields
Instead of writing to formula fields, update the fields used in the formula.
Solution 4 — Review API payload
Ensure integrations do not include restricted fields when inserting or updating records.
Pro Tip: Use describe metadata in Apex to check if a field is updateable before performing DML.