Salesforce Decode
Salesforcedecode
Back to questions
IntegrationAdvancedpolymorphicmappingdata-model

Handle polymorphic lookups in integration mappings

Real World Scenario

Task WhoId polymorphic field breaks warehouse ETL expecting Contact foreign key only.

Expected Answer

• Split WhoId into ContactId LeadId columns in staging with type discriminator • Integration layer resolves polymorphic to concrete type before load • Document polymorphic fields avoided in new custom integrations • SOQL TYPEOF for polymorphic query in Apex middleware • Warehouse star schema optional polymorphic bridge table • Validation rejecting ambiguous polymorphic on inbound API

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Direct answer: Split WhoId into ContactId LeadId columns in staging with type discriminator Also consider: Integration layer resolves polymorphic to concrete type before load In practice: Document polymorphic fields avoided in new custom integrations Optimize for scale and operational observability.

Architect Perspective

Polymorphic fields are integration kryptonite—flatten at boundary layer.