function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bob 11Bob 11 

Flow Error: This error occurred when the flow tried to update records: Too many SOQL queries: 101

I have a flow that is trying to update records, but users are getting the following error message

This error occurred when the flow tried to update records: Too many SOQL queries: 101

Is there any criteria I can add to the update element to stop this from happening? 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Bob,

This error is because your flow is not bulkified. If your flow has some SOQL in loop then it may cause the issue.

Please find the below article which shows the best pratices while creating flows.

https://succeedwithsalesforce.com/5-best-practices-that-must-be-followed-when-building-flows/

If this solution helps, Please mark it as best answer.

Thanks
Hara SahooHara Sahoo
From the documentation:
A transaction ends as soon as a flow interview begins to wait for an event. When the flow interview resumes, a new transaction begins. Everything after the Wait element is executed as part of a batch transaction that includes other resumed interviews. [...]
Consider using multiple Wait elements so that the DML operations and SOQL queries are performed in multiple transactions.

if your flow is an Auto launched flow, add a pause element and configure it to resume your flow after 0 hours of current date-time.
Please note that pausing the flow makes the rest of the flow run asynchronously in a separate transaction.

User-added image


 
Bob 11Bob 11
Thank you for helping, but my flow does not have a loop. This flow was built by someone else, so i am not sure how to bulkify.
User-added image
User-added image
User-added image
User-added image
User-added image

 
Bob 11Bob 11
I only have these elements 

User-added image
Bob 11Bob 11
The error is coming from the Get_Service_Appointment element. Is their something i can add to that element to stop this error?

Error element Get_Service_Appointment (FlowRecordLookup).
This error occurred when the flow tried to look up records: Too many SOQL queries: 101.
ravi soniravi soni
hi Bob,
As far as i think, trigger is excuting and this error is coming due to trigger. when you try to update any records from flow at that time trigger is excute. check trigger in your org before and after case.

run below query in query editor and check.
SELECT Id, Name, TableEnumOrId, UsageBeforeUpdate, UsageAfterUpdate FROM ApexTrigger Where  TableEnumOrId = 'YourObjectName'

maybe you will find any way.
don't forget to mark it as best answer if it helps you.
Thank you
Bob 11Bob 11
Hello Veer,
I ran the query, but i'm not sure what it tells me
User-added image
ravi soniravi soni
hi bob, 
In this screenshot I am able to see that you have a one active beforeUpdate trigger on serviceappointment you can deActive it once and than you can run your flow check afterUpdate trigger on same object as well and if that is also active then you do deActive it and then run your flow.
It seem to me that this time it will work fine.

How to deActive trigger
go to your serviceAppointment object and open the trigger tab and open  your  active trigger => click edit => deActive and then save.

don't forget to mark it as best answer.
thank you