Try Serpent Free

How to fix REQUIRED_FIELD_MISSING in Salesforce deployments

A record is missing a value for a field that is marked required in the target org.

Surfaces during: runtime DML, most often Apex test execution or a data load

What it means

REQUIRED_FIELD_MISSING means a record insert or update left out a field the target org requires a value for. This is often environment-specific: the field's required setting, or the automation that normally fills it in, can differ between the source and target org.

A field can be required in two different ways, marked required at the field-definition level, or required only on a specific page layout, and the two behave differently: layout-level required fields are enforced by the UI but not by the API or Apex, which is a common source of confusion when a save succeeds through Apex but would have been blocked in the browser.

Diagnosis

Common causes

Test factory does not populate a newly required field
A field recently became required in the target org, but the Apex test data factory that builds records was never updated.
Required setting differs between environments
The field's required flag was changed in one sandbox but not promoted to the target org, or vice versa.
Default-value automation is skipped in test context
A flow or trigger that normally populates the field does not run, or is deliberately bypassed, during the deployment's test execution.

The fix

  1. Update the test data factory
    Add the missing field to every place Apex tests build that object, so required fields are always populated.
  2. Sync the required setting across orgs
    Deploy the field's required flag as part of the same change set so source and target orgs match.
  3. Confirm default-value automation runs
    Check that any flow or trigger responsible for defaulting the field is active and not bypassed in test context.
In practice

How Serpent prevents this

Serpent AI's environment diff surfaces required-field mismatches between source and target org before a deployment runs, not after it fails. See the Salesforce deployment error library.

Metadata and data in one deployment flow in Serpent

Prevention

Build test data factories from live schema, not a hardcoded field list
Read required fields off the object's describe result when building test records, so a newly required field is caught automatically instead of failing silently in CI.
Distinguish field-required from layout-required in code review
Flag any change to a field's required-at-definition setting for review separately from layout-level required changes, since only the former affects Apex and API inserts.
Ship a field's required flag with any automation that depends on it
Bundle the field metadata change and the default-value Flow or trigger in the same deployment, so they never land out of sync.
Common questions

REQUIRED_FIELD_MISSING, answered

Why does the same Apex test pass in one org but fail in another?
The field is likely required in one org and optional in the other. Compare the field's required setting between the two environments.
Does a required field on a page layout block an Apex insert?
No. Page-layout-level required settings are enforced only in the UI. Apex and API inserts are only blocked by fields marked required at the field-definition level.
Does this error tell me which specific field is missing?
Usually yes. The error text typically lists the API name of the missing required field or fields directly, so start there before checking the object's full schema.

Start free. No credit card, no install, no commitment.

Set up in under 15 minutes. No DevOps hire needed.

Curious about faster shipping before you dive in? Let's talk

Commitment free!