Essentially what is happening here is a lookup is done on our Users objects to find users that need to be included in a lead reassignment for that business day (lets say its a Wednesday). I have a custom field Users object that can include or exclude them for the flow. After its gets a list of Users it gets a list of their Leads that fall within a certain criteria (not all of them). If those leads match that criteria, the recordID gets pushed over to an apex class that round robins that lead to another User.

Usually this is a small amount of leads each day (our reps are pretty much on top of it) but Im developing it out incase one of the days of the week its more leads then usual and thats where im running into the limit during testing. Ive created a counter and and pause if my counter gets close to my limit. The pause element doesnt seem to reset the governor limit, as Im still getting the 101 SOQL query error.

Included is a screenshot, is there anything Im missing here?

enter image description here

  • Does the Apex code execute any queries?
    – sfdcfox
    Sep 6, 2020 at 18:56

1 Answer 1


You have a query and presumably a DML inside of loops. This is definitely against best practices. Instead, you should query all the leads you need at once, process all the ID values, then pass them to your Apex. Presumably, you'll need to modify your Apex to support this bulkification.

@InvocableAction(label='Send to Round Robin')
public static void sendToRoundRobin(List<List<Lead>> records) {
  List<Lead> leadRecords = new List<Lead>();
  for(List<Lead> leadRecordList: records) {
  // now process leadRecords in bulk.

Your flow should look like:

Example Flow Design

You must log in to answer this question.

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