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
Nidish G 6Nidish G 6 

How to avoid soql limits in flows

Is there any way to optimize the flow in order to avoid soql limits
AbhishekAbhishek (Salesforce Developers) 
There is no Offical way but you can try the below suggestions as mentioned in the below developer discussion,

https://www.reddit.com/r/salesforce/comments/dl563f/is_there_a_workaround_for_a_systemlimitexception/

I hope it helps.
ShirishaShirisha (Salesforce Developers) 
Hi Nidish,

Greetings!

Please refer the below thread to break the transactions in the flow to avoid hitting the SOQL limits:

https://salesforce.stackexchange.com/questions/261532/breaking-a-flow-into-2-different-transactions

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri
AnudeepAnudeep (Salesforce Developers) 
TOO_MANY_SOQL_QUERIES :101
  • Flows are subject to governor limits and similar to Apex, you need to ensure that the Flows respect those limits otherwise there can be consequences. Be it auto-launched flows or screen flows, both should be designed in a manner where they only query, create or update the needed records and do not perform a superfluous action.
  • Remember that when you are creating Flows, you are sort of writing Apex via the UI so similar concepts/limits apply to Flows as well similar to limits in apex class. A Record Lookup or Record Update or Record Create element should be avoided inside a Loop element at all costs
  • If in case of bulk updates, the flow will be executed multiple times
  • When flows are launched from workflow rules that are triggered by bulk loads or imports, the flows’ data manipulation language (DML) operations are executed in bulk to reduce the number of calls required and to optimize system performance. The execution of any of the following flow elements qualifies as a DML operation: Record Create, Record Update, Record Delete, Fast Create, Fast Update, or Fast Delete.
  • For example, suppose that you use Data Loader or the Bulk API to update 50 records, and those updates meet the criteria of a workflow rule with a flow trigger action. In response, the system executes 50 instances of the flow within the same transaction. Each instance of a running flow is called an interview. The system attempts to execute each DML operation across all the interviews in the transaction at the same time. Suppose that five of those interviews are executing the same branch of the flow, which has a Record Update element called “SetEntitlement.” The system waits for all five interviews to reach that element, and then executes all five record updates in bulk.
Resolution:
  • Bulkify the flow by using Fast update instead of Record update
  • Use Decision elements to Update only when needed:- Only the records that need to be updated, should be evaluated and updated within the Flow
Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you