Salesforce Decode
Salesforcedecode
Back to questions
ApexIntermediatebulkificationdmltriggers

Avoid DML in loop when cascade updates touch six child object types

Real World Scenario

Contract activation trigger updates Status on Quote, Order, Asset, Entitlement, Subscription, and Invoice child records one DML per child per Contract.

Expected Answer

• Collect all child record updates in typed lists per object type • Single DML per object type: update all Quotes, then all Orders, etc. • Query all children in one SOQL per type using ContractId IN :contractIds • Governor limit: 150 DML statements—six types safe but watch per-record loops • Consider Platform Event fan-out if child update logic is independently complex • Test 200 Contract bulk activation measuring DML statement count • Document master-detail cascade vs manual child update ownership

Follow-Up Questions & Answers

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

Main difference: use case and scale. Collect all child record updates in typed lists per object type. Single DML per object type: update all Quotes, then all Orders, etc. Pick based on your integration pattern and team capability. DML per record is beginner mistake; DML per object per trigger pass is the standard. Balance speed of delivery with maintainability.

Architect Perspective

DML per record is beginner mistake; DML per object per trigger pass is the standard.