0% found this document useful (0 votes)
2 views16 pages

DML and Soql

Uploaded by

prabathkotti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views16 pages

DML and Soql

Uploaded by

prabathkotti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

When using the Update Records element, it's

crucial to know how it uses up two key limits:

DML Statements and SOQL Queries.

Let’s dive into what these limits are and how


they get used in Before & After-Save Flows.

But, before we start:


Before-Save Flows are called Fast Field
Updates in the Flow Builder.

After-Save Flows are called Actions & Related


Records in the Flow Builder.

I’ll use the terms Before & After-Save Flows.

OK, let’s dive into the two critical limits:


DML Statements:

Each time a record in the Salesforce database


changes, 1 DML Statement gets used.

Automations can use a max of 150 DML


Statements. They fail if they try to use 151.
SOQL Queries:

Each time an automation searches for a record


in the database, 1 SOQL Query gets used.

Automations can use a max of 100 SOQL


Queries. They fail if they try to use 101.
An Update Records has different methods you
can select to update a record.

These methods don’t all use SOQL Queries and


DML Statements the same.

So, let’s dive into each method in an Update


Records and analyze how these limits get used.
Here are how the different options in Method 1
use DML Statements & SOQL Queries:
Using the Update Records element to update
“the record that triggered the Flow”
Type of Flow Filter DML SOQL Queries
Update conditions in Statements Used:
Records is Update Used:
used in? Records?
Before-Save No 0 0
Before-Save Yes 0 0
After-Save No 1 0
After-Save Yes 1 0
Here is how Method 2 uses DML Statements
& SOQL Queries:
Using the Update Records element to “update
records related to the record that triggered the
Flow.”
Type of Flow Filter DML SOQL Queries
Update conditions in Statements Used:
Records is Update Used:
used in? Records?
After-Save No 1 1
After-Save Yes 1 1
Here is how Method 3 uses DML Statements
& SOQL Queries:
Using the Update Records element and
using “the IDs and all field values from a
record or record collection”:

● DML Statements Used: 1


● SOQL Queries Used: 0

Now for our last example:


Here is how Method 4 uses DML Statements
& SOQL Queries:
Using the Update Records element to
“specify conditions to identify records, and
set fields individually”:

● DML Statements Used: 1


● SOQL Queries Used: 1

So, what are the key takeaways from the 4


methods?
Updating a related record with a Record
Variable doesn’t use a SOQL Query, unlike
other methods.

Use Record Variables when the ID of the


record you want to update is available in
your Flow without a Get Records.

For example:
In an Opportunity After-Save Flow, the
parent Account ID is available in the
$Record variable.

This means you can create an Account


Record Variable for the parent Account and
assign its ID and needed field values to it.

You can then update it with 0 SOQL Queries.


Final key takeaway:

Update Records in Before-Save Flows never


use DML Statements.

They always do in After-Save Flows.

Use Before-Save Flows when you can.

You might also like