-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathDMLStatementInLoop.ts
More file actions
26 lines (24 loc) · 1.04 KB
/
DMLStatementInLoop.ts
File metadata and controls
26 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { FlowType, IRuleDefinition } from "../internals/internals";
import { LoopRuleCommon } from "../models/LoopRuleCommon";
export class DMLStatementInLoop extends LoopRuleCommon implements IRuleDefinition {
constructor() {
super({
ruleId: "dml-in-loop",
category: "problem",
description: "Executing DML operations (insert, update, delete) inside a loop is a high-risk anti-pattern that frequently causes governor limit exceptions. All database operations should be collected and executed once, outside the loop.",
summary: "DML operations inside loop risk governor limits",
docRefs: [
{
label: "Flow Best Practices",
path: "https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5",
},
],
label: "DML Statement In A Loop",
name: "DMLStatementInLoop",
supportedTypes: FlowType.backEndTypes,
}, { severity: "error" });
}
protected getStatementTypes(): string[] {
return ["recordDeletes", "recordUpdates", "recordCreates"];
}
}