Salesforce Decode
Salesforcedecode
Back to questions
ApexAdvancedacrb2brelationships

Handle AccountContactRelation in Apex for multi-contact roles

Real World Scenario

B2B portal must display all buying committee contacts with roles but triggers only handled primary Contact.

Expected Answer

• Query AccountContactRelation for role-aware contact lists • Triggers on ACR maintain rollup counts per role • Bulk-safe ACR DML when importing relationship CSV • Distinguish direct Contact.AccountId vs ACR many-to-many • Validation preventing duplicate roles where business forbids • Test person account edge cases separately • API returns ACR collection not single primary contact

Follow-Up Questions & Answers

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

Main difference: use case and scale. Query AccountContactRelation for role-aware contact lists. Triggers on ACR maintain rollup counts per role. Pick based on your integration pattern and team capability. B2B relationship model is ACR-first—primary contact field alone is legacy thinking. Optimize for scale and operational observability.

Architect Perspective

B2B relationship model is ACR-first—primary contact field alone is legacy thinking.