Skip to main content

SF-0038 · Scenario · Medium

Can we create Lookup relationship on an object which already have existing data?

✓ Verified by Vikas Singhal · Last reviewed 5/17/2026

Yes — you can create a Lookup relationship on an object that already has data, with no restrictions. Existing records simply have the new lookup field empty (null). Salesforce does not check that every row references something — Lookup is, by default, optional, and even when marked Required it only enforces the constraint on new and edited records going forward, not on existing ones (until they’re edited).

This is one of the key differences between Lookup and Master-Detail.

What happens when you add a lookup to a populated object

  1. The new field is created with a default value of null on all existing records.
  2. The related list automatically appears on the parent (subject to page layout config).
  3. Reports, list views, and SOQL immediately recognize the field.
  4. Users can populate it manually, via data loader, via flow, or via integration.

If the lookup is marked Required:

  • New record creation must supply a value, or save fails.
  • Existing records with null values stay null until someone edits them — at which point the user must supply a value before save.

This is the platform being pragmatic: a strict “must-have-value” rule is enforced going forward but doesn’t break what’s already there.

Compare to Master-Detail

For master-detail, Salesforce blocks creation of the field if any existing record would end up without a parent. You’d see an error like “Cannot create relationship: object has existing records.” The fix is the well-known lookup → master-detail conversion pattern:

  1. Add the field as a Lookup first.
  2. Backfill the lookup value on every existing record (data loader, flow, mass update tool).
  3. Verify zero nulls remain.
  4. Convert the field to Master-Detail.

Step 4 fails if any record still has a null. Once every row has a parent, the conversion succeeds.

Practical scenario

“You inherited an org with 50,000 existing Project__c records and now need to relate them to a new Customer__c object.”

Plan:

  1. Create Customer__c and load customer data.
  2. On Project__c, add a Lookup field Customer__cCustomer__c. (No error — existing data is fine.)
  3. Use a flow or Apex script to populate Project__c.Customer__c from existing data (perhaps matching on Account name, customer code, or a manual mapping table).
  4. Run reports to check coverage; clean up the unmapped rows manually.
  5. If business rules say every project must have a customer, mark the field Required at this point.
  6. If you want roll-up summaries on Customer, convert to Master-Detail (only safe after step 4).

Things to watch out for

  • Bulk edits: If you mark the lookup Required, users who edit a record without setting the lookup will hit validation. Plan a remediation window before flipping the switch.
  • Validation rules: Existing validation rules referencing the new field will evaluate against null until populated — review them for unexpected NPE-like behavior.
  • Reports: Reports filtering on the new field need to handle “is null” explicitly during transition.
  • Integrations: Outbound integrations that consumed the parent record may now expect the new field — coordinate before adding.

Quick summary table

ActionAllowed on object with data?Notes
Add Lookup (optional)Yes — alwaysExisting records null until edited
Add Lookup (required)Yes — but applies only going forwardExisting nulls allowed; future edits must populate
Add Master-DetailNo — blocked if any existing recordsUse lookup → backfill → convert pattern
Convert Lookup → Master-DetailOnly if zero nulls in the lookupStrict pre-flight check
Convert Master-Detail → LookupYes; must first delete dependent roll-upsReverse of above

Verified against: Salesforce Help — Lookup Relationship Considerations. Last reviewed 2026-05-17.