Rule registry · FL-004

No DML inside loops

Checked by the Salesforce Flow scan. Severity high.

FL-004HighPerformance

What it requires. Get Records, Create Records, Update Records, and Delete Records elements must not appear inside a Loop element in record-triggered or autolaunched flows.

Why it matters. Each SOQL query inside a loop counts against the per-transaction limit of 100 synchronous SOQL queries. Each DML statement inside a loop counts against the limit of 150 DML statements per transaction. Each DML-affected record counts against the 10,000 DML rows limit. A loop processing 101 records with a Get Records element will throw a System.LimitException and halt the entire transaction mid-execution, leaving records in a partially updated state.

How to fix it. Move all Get Records and DML elements outside the loop. Use Assignment elements inside the loop to build collections, then perform a single bulk DML operation after the loop completes.

Source. Apex Developer Guide: Execution Governors and Limits (100 SOQL queries / 150 DML statements per synchronous transaction). Practice guidance: Salesforce Admins Ultimate Guide – Being careless when looping

Is this rule worth checking?

Votes and comments are published here. We read them, and we publish what we change with the reasoning — a vote does not move a rule on its own.

Every rule we check, every source, and every one we turned down