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
Nithyanandha NimmalaNithyanandha Nimmala 

Salesforce Flows : Too many SOQL Queries 101


I came across an error in which I got in a record triggered flow Too many SOQL Queries). It is a. In which a "get record" element which queries contacts by comparing the ids present in another list and having couple of other conditions which checks whether some fields should not be null. The flow element is not present in any loops. can you please tell me in which other direction i can look to solve this issue
Best Answer chosen by Nithyanandha Nimmala
Arun Kumar 1141Arun Kumar 1141

Hi Nithyanandha,

In order to resolve a "Too many SOQL Queries" problem in a record-triggered flow, you can try the following strategies:

1. Bulkification: Make sure your flow is set up to effectively handle bulk records. You have used more SOQL searches than allowed, according to the error notice. The number of inquiries may exceed the governor restrictions if the flow is simultaneously being initiated for several records. Check the flow's architecture to make sure it can manage large numbers of records and reduce the amount of SOQL queries issued.

2. Query Optimisation: Examine your flow's SOQL queries to see if they can be made more efficient. Find ways to slash the amount of inquiries or combine them into one more effective query. If applicable, take into account relationships or aggregate inquiries.

3. Review the criteria used in the "get record" element when considering filtering and filtering logic. To decrease the amount of records obtained, see whether the criteria may be improved or made simpler. Make sure the criteria are limited and prevent the querying of a huge number of records.

4. Check the running user's access to the records being requested to see whether it is suitable. Make sure the user has read access to all required fields and objects. Check to see if there are any record-level security settings or sharing restrictions that might affect the records you've collected.

5. Recursive Calls: Your flow may result in recursive calls and excessive SOQL searches if it contains any subflows or calls other processes that might possibly cause the same flow to be triggered again. Make sure your flow is not self-triggering or becoming stuck in a loop.

6. Other Flow Elements: Examine the other components to make sure they aren't leading to more requests. Check to see whether any record update or creation components, for instance, are running extraneous queries.

7. External Data Sources: Ensure that the external data sources are correctly set and optimised if you're utilising External Objects to query data from external systems. The SOQL query restrictions may also apply to external queries.

You should be able to find the possible reasons of the "Too many SOQL Queries" error by looking into these areas, and you can then make the appropriate modifications to fix the problem.

Thanks,