0

Thanks in advance for the help on this. We're at a hold until we can get this problem fixed. Here's our process:

  • Every day we run an update import of all trial accounts from the prior three month window to update their information in salesforce. Typically around 1-2k records.
  • We have a process that is set to evaluate the account records when they're edited and mark qualified if criteria is met.
  • The process isn't triggering because we're going over our limit and I'm unsure how to fix it.

Here's the process criteria: Start object: Account When conditions are met,

  • Account number of employees greater than or equal to 30 OR
  • Account Users greater than or equal to 6 OR
  • Account Plan is equal to Plus

Action: Mark as qualified

Evaluate the next criteria,

  • If qualified is equal to true AND
  • Source: Trial import AND
  • Account type equals Prospect

Action: Create opportunity

Here is the error message being sent out:

Error Occurred: Too many SOQL queries: 101
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: Mark_Accounts_as_Qualified_Add_Opportunity
Type: Workflow
Version: 6
Status: Active
Flow Interview Details
Interview Label:
Current User: Tim Thyne (00541000000cVgq)
Start time: 9/20/2016 8:41 AM
Duration: 0 seconds
How the Interview Started
Tim Thyne (00541000000cVgq) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 00141000002PNY7AAO
myVariable_current = 00141000002PNY7AAO
RecursiveCountVariable = 0.00
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime} Result
{!myVariable_waitStartTimeVariable} = "9/20/2016 8:41 AM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: or
1. {!myVariable_current.Number_of_Employees_CB__c} (5) Greater than or equal 30
2. {!myVariable_current.Users__c} (9) Greater than or equal 6
3. {!myVariable_current.Plan__c} (Plus) Equals Plus
Logic: One condition must be true (OR)
RECORD UPDATE: myRule_1_A1
Find all Account records where:
Qualified__c Equals false
Id Equals {!myVariable_current.Id} (00141000002PNY7AAO)
Update the records’ field values.
Qualified__c = true
Result
Failed to update records that meet the filter criteria.

5
  • 2
    Looks like a recursive problem. Updating the same record which again satisfy the same criteria.
    – Ashwani
    Sep 20, 2016 at 13:02
  • @ashwani thanks for the help on this. Is there something I should change to prevent this from occurring? I'm lost and unsure how to fix it.
    – Tim Thyne
    Sep 20, 2016 at 13:07
  • I believe you can add a flag/check once the operation is completed. And when it fires the same operation again you would check that flag status to decide whether the process should execute or not. Hope I could make any sense.
    – Ashwani
    Sep 20, 2016 at 13:09
  • I just tried checking that box in the process builder and will see if that prevents it.
    – Tim Thyne
    Sep 20, 2016 at 13:50
  • Add an additional check to your original criteria for Account Qualified = False, that way you won't run your "Mark as qualified" criteria over and over on a record that is already qualified. If Account Qualified is false and meets all other conditions, it will be marked as qualified, and then when it loops through that record again it will skip it because Qualified != false anymore. Make sense? Sep 20, 2016 at 15:23

1 Answer 1

5

Using your own log as an example:

DECISION: myDecision

Executed this outcome: myRule_1

Outcome conditions: or

  1. {!myVariable_current.Number_of_Employees_CB__c} (5) Greater than or equal 30

  2. {!myVariable_current.Users__c} (9) Greater than or equal 6

  3. {!myVariable_current.Plan__c} (Plus) Equals Plus

Logic: One condition must be true (OR)

^^ When the above conditions are met... Update Records THAT MEET Criteria (SOQL Query):

RECORD UPDATE: myRule_1_A1

Find all Account records where: <<< SOQL QUERY

Qualified__c Equals false

Id Equals {!myVariable_current.Id} (00141000002PNY7AAO)

^^ Each of these is a SOQL Query (SELECT Qualified__c FROM Account Where Qualified__c = false AND Id =:currentId)

Update the records’ field values.

Qualified__c = true


So, every time your process runs it evaluates any of 3 possible (OR) conditions. Since one of those conditions isn't to check if Qualified__c is ALREADY true, it includes ALL accounts that meet the criteria, even if we've already flagged them as qualified before (Qualified__c = True).

THEN, you start a record update on every record. In order to find the records that are already Qualified__c, you are deciding to only update records of a certain criteria (Qualified__c equals false). This requires a SQL query for each record in your import, regardless of whether or not they've already been marked as Qualified.


You could consider adding an AND check to your original conditions:

(Number_of_Employees_CB__c >= 30 OR Users__c >= 6 OR Plan__c = 'Plus') AND Qualified__c = false

This way, we're excluding any records where Qualified__c = True BEFORE doing record update, and we can probably change the Record update from "Updated records meet all conditions" to just a plain old "No criteria--just update the records", which should result in less recursion/less unnecessary SOQL queries - or none at all if you completely remove the update criteria since you'd be already checking that criteria during your initial Criteria check.


I hope this makes sense - gotta be careful when you use process builder because it IS restricted to the same governor limits as standard Apex since it functions in similar ways (SOQL queries and conditional updates). If you're still having trouble even after these types of changes, you might even want to consider moving your initial conditions/field update action for Qualified__c = True to a standard workflow rule since they aren't bound to the same governor limit issues as process builder is. If you go that route, you could move your OR/AND conditions (Employees, Users, Plan and Qualified__c status check) to a Workflow rule, then have a field update set Qualified__c = true when a record meets conditions, then build a new proc builder that runs when conditions are met and have it just check if Qualified__c was just set to true in the latest DML update and if so create opportunity.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .