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
NevDevNevDev 

Error Occurred: Too many SOQL queries: 101 on Process Builder

Guys we are getting multiple "Too many SOQL queries: 101" emails at the moment. We are using Classic.
We have not used any triggers just Process Builder for various functionality requirements. 
I have read on one of the ideas that this had been resolved and Process Builder is now "bulkified".
Can anyway guide me as to how we can resolve this
Would this only occur if there is a mass upload of records to the object where the Process Builder is built on?
Best Answer chosen by NevDev
PawanKumarPawanKumar
Hi NevDev,
This is a known issue in salesforce as of now. you can refer below link for the same.
To confirm, you can raise case with salesforce support for the same.
https://success.salesforce.com/issues_view?id=a1p3A0000001C7cQAE

https://success.salesforce.com/ideaView?id=08730000000DhBlAAK

Workaround: A trigger with a list and SQL query outside any loops can solve your problem. This is the only solution we have, as of now.

Regards,
Pawan Kumar

All Answers

PawanKumarPawanKumar
Hi NevDev,
This is a known issue in salesforce as of now. you can refer below link for the same.
To confirm, you can raise case with salesforce support for the same.
https://success.salesforce.com/issues_view?id=a1p3A0000001C7cQAE

https://success.salesforce.com/ideaView?id=08730000000DhBlAAK

Workaround: A trigger with a list and SQL query outside any loops can solve your problem. This is the only solution we have, as of now.

Regards,
Pawan Kumar
This was selected as the best answer
NevDevNevDev
Thanks Pawan
Rebecca RallsRebecca Ralls
For anyone else looking for this - there is now a "Bulkification" setting that Salesforce can activate. Log a case under workflow automation.
ChellappaChellappa
@Rebecca Ralls,

hi Rebecca,
Is this something only Salesforce can enable?
We are getting a different issue with Process Builder( i can't confirm this for sure)
When we are updating Opportunity, based on Event monitoring by Salesforce support, they are saying Process builder is taking long time.

That makes me think , are Process Builder really bulkified?

So here is my question:
If we upload 10 Opportunities in one shot, and there are a process builder on Oppty, will it execute for each of the 10 Oppty Records, or execute once for all 10?

The reason i am asking is - our process builder updates child records. So i am just wondering if the process builder updates all Child records together or separately for each Oppty Id
Thanks in advance for any guidance. 

Thanks,
Chellappa
Rebecca RallsRebecca Ralls
Yes - to try to address this issue, I would log a case as I recommended above in addition to enabling the critical update "Execute All Flow Interviews When Invoked in Bulk"
Jay SrinvasanJay Srinvasan
Thank you Rebecca.

I was getting the same error Too many SOQL queries from the process builder. I activaed the critical updates "Enable Flow and Process Queries to Execute in Batches". It worked! This patch does bulkified the process queries.
Alyssa HyemAlyssa Hyem
Does anyone know if a case, "Bulkification Setting" is still required or will the critical update handle this????
Rebecca RallsRebecca Ralls
I would try enabling the critical update and see if it fixes it - and if not, then go to Salesforce with a Case.
Shubham KherdeShubham Kherde
Hi all,
I am facing Too many SOQL queries: 101 error for following code but as per governor limit my SOQL Query is outside the for loop still getting this error and also showing following process builder error with this
 
 ( 09:59:49:020 EXCEPTION_THROWN [184]|System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Update Oppty Lookup RelatedTo Events 2 test” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to update records: LIMIT_EXCEEDED: System.LimitException: Too many SOQL queries: 101. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1987318438-82422 (-64273350): []   )
 
  Map<Id, Opportunity> oppdbmap = new Map<Id, Opportunity>(
            [select Id, Booked__c, Initial_Appt_Date_Time__c, Initial_Appt_Time__c,
                (select Id, Subject, ActivityDateTime from Events where What.Type = 'Opportunity' and ActivityDateTime != null and Subject != 'Cancelled Appointment' order by ActivityDateTime desc limit 1) 
             from Opportunity where Id in: oppevmap.keyset()]);

        // if an existing event is more recent than a new one, we will use an existing one
        for (Id oid: oppevmap.keyset()){
            Event etempnew = oppevmap.get(oid);
            Opportunity oppdb = oppdbmap.get(oid);
            Event etempdb = oppdb == null ? null : oppdb.Events == null ? null : oppdb.Events.isempty() ? null : oppdb.Events[0];
            if (etempdb != null && etempdb.ActivityDateTime != null){
                if (etempnew == null || etempnew.ActivityDateTime == null || etempdb.ActivityDateTime > etempnew.ActivityDateTime){
                    oppevmap.put(oid, etempdb);
                }
            }               
        }

would anyone know how I can fix?

Thanks,
Shubham Kherde


 
Hari KundrapuHari Kundrapu
@Shubham Kherde,
If you are getting this error after activating critical update "Execute All Flow Interviews When Invoked in Bulk"

Consider the following:
If you have Before and After Triggers and if there is a flow that is invoked from a Process Builder. Then there is a high possibility that your Triggers might be executing one more time and increasing the number of SOQL in a Transaction.

In order to check it:
Increase your Debug Logs of Workflow, Apex, System, Database to higher levels.
1. DeActivate the Process Builder - Edit and Save any record for that object. Open the latest debug log and note down the SOQL Queries Used(Last one).
2. Activate the Process Builder - Edit and Save the same record. Open debug log and note down the SOQL Queries Used.
If the #SOQL difference is doubled then your Triggers are looping once again. In that case, you may need to check how to stop recursive triggers (Mainly for after Triggers).

Another one to try,
Add a fault line to Record Lookup or Record Update. So, that the internal process may handle if Too many SOQL queries error popup in error.
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_considerations_design_wait.htm?search_text=Too%20%20many%20SOQL

Thanks,
Hari Kundrapu
Ranjeet Kumar 16Ranjeet Kumar 16
Hi Rebecca, can you please confirm if it is working with critical Update setting only or not.