I created a flow that captures the 'Duration' spent in each Opportunity Stage. When I run the flow I am getting the following error: System.LimitException: Too many SOQL queries: 101. I know it is related to hitting a SOQL query limit- but am not sure where my Flow is causing this.

Here is a brief overview:

Triggered on 'Opportunity' object -> I get the field values for the record that triggered the Flow to run -> Decision tree checks the Opportunity for which Stage is 'Prior' and which Stage is 'Current'. Then I update the Record.

enter image description here

Here is more detailed Nodes:


enter image description here

Get records:

enter image description here


enter image description here

Update records:

enter image description here

2 Answers 2


Looking at the flow looks like your Flow is running in recursion. This simply means you are triggering a record and updating same record which in turn again triggers the flow causing a never ending infinite loop ultimately causing 101 SOQL exception.

I suggest use the Before Save update flows. That way you just use fast field updates instead of trying to use the update record element.


Four things which you can do in order to make this flow "better" and consuming less limits.

  1. Use Fast Field Updates on Start element.
  2. Select "When to Run the Flow for Updated Records" -> "Only when a record is updated to meet the condition requirements" so it won't run multiple times (of course if you want to change record data only once)
  3. You don't need to use Get Record element for fetching opportunity data. You are fetching Opp which triggered the flow. Because of that you can use Assignment element directly on $Record variable. Decision also.
  4. Use "Use the opportunity record that triggered the flow" on the Update element.

If any other automation is not causing your issue, you should actually get rid of your exception.

You must log in to answer this question.

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