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
Lindsay JonesLindsay Jones 

LIMIT_EXCEEDED: System.LimitException: CFL:Too many SOQL queries: 101

Hello!

I created an autolaunched flow that is started via process builder. When trying to create a new contact, I get the following error email:

Error element Update_County (FlowRecordUpdate).
The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: CFL:Too many SOQL queries: 101. For details, see API Exceptions.

This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.

Flow Details
Flow Name: Lookup_zip_county
Type: Autolaunched Flow
Version: 2
Status: Active

Flow Interview Details
Interview Label: Lookup zip/county 1/31/2018 4:19 PM
Current User: General User (00515000006mz1Z)
Start time: 1/31/2018 4:19 PM
Duration: 0 seconds

How the Interview Started
General User (00515000006mz1Z) started the flow interview.
Some of this flow's variables were set when the interview started.
VAR_AccountID = 0011C00001t5Ow4QAE
VAR_Zip = 97212

RECORD QUERY: Find_zip_county
Find one County__c record where:
Zip_Code__c Equals {!VAR_Zip} (97212)
Result
Successfully found record.
{!VAR_County} = Multnomah

RECORD UPDATE: Update_County
Find all Account records where:
Id Equals {!VAR_AccountID} (0011C00001t5Ow4QAE)
Update the records’ field values.
Auto_County__c = {!VAR_County} (Multnomah)
Result
Failed to update records that meet the filter criteria.

Error Occurred: The flow tried to update these records: null. This error occurred: LIMIT_EXCEEDED: System.LimitException: CFL:Too many SOQL queries: 101. For details, see API Exceptions.

My goal in creating the flow was to autopopulate county based on zip code. To do this, I created a custom object with records for each related county and zip code. I will screenshot my flow, but basically, process builder feeds the flow an accounts zip code, which it looks up from the custom records, and then the flow updates the county field.

The flow is set to run when an account is "created or edited" and the criteria labeled "None" says "nothing, just execute!".

User-added image

User-added image
User-added image
User-added image



Thank you for any help you can provide to get around the limit and get this working!

Many thanks,
​Lindsay
 
Gaurav HandooGaurav Handoo
Hi Lindsay

Few things that might help:
  1. User-added image
  2. Make sure recursion is marked as false
  3. Add a decision box criteria saying:
    1. <Zip Code fied on Account> is changed


This would force your Process Builder to only fire whenever that particular field is updated (includes creation and updation both) and will not recursively update your account.

P.S. Assumption here is that there are other triggers that are updating your account, which results in firing this Process Builder again.

Hope this helps. Mark as best answer if this helped.

Cheers!!
 

Gaurav

Lindsay JonesLindsay Jones
Hi Gaurav,

Thank you for your response! Is changed works to fix the limit issue and I can now create contacts again, BUT this solution creates other data issues. I can't see why they're related, but perhaps you can help.

Contacts often submit their full 9-digit zip codes. The custom object I created is built with 5-digit zip codes that correlate to counties. To fix this issue, I have 2 formula fields on the account record:
  1. "Admin Text Account Zip" - This copies the Account Billing Zip to text so the following fomula field will work...
  2. "Admin Short Billing Zip" - LEFT( Admin_Text_Account_Zip__c , 5)
I then feed the Admin Short Billing Zip into my Process Builder/flow (shown above) so that it can lookup the 5-digit zip and populate the associated county. Now for the weird part... when I add the "ISCHANGED(Billing Zip)" as a criteria in process builder, the county will not populate if the account is created or updated with a 9-digit zip code... even though the Admin Short Billing Zip is feeding the flow a valid 5-digit zip.

The 9-digit zip codes worked just fine without the ISCHANGED criteria.

Any ideas on why this could be and how to fix??

Thanks!!

Lindsay
Gaurav HandooGaurav Handoo
Hi Lindsay

Change in Formula field doesn't fire an event to be captured. Instead, you would need to do the following:
  • Invoke your flow on change of Original Zip code field.
  • In your flow:
    • Create a Formula with LEFT( <Variable to capture 9-digit character> , 5). This would trim the 9-digit code to 5 digit (as it does on normal fields).
    • In Record Lookup, change your condition to search the formula variable generated.
Hope this helps.

Cheers!!

Gaurav