0

I created a flow that is supposed to remove manual sharing of contracts when editing the field on the contact. The contract owner (partner user) has a custom field in which I enter the manager and the previous manager. For new it creates manual sharings, and for old (separate flow) removes access. Unfortunately, I get the error "Too many SOQL queries: 101" during the loop, which checks which of the user's contracts had contract_sharings created.

Is there any way to get around the above error? Flow

3
  • Are you able to write Apex?
    – Robs
    Commented Jan 28, 2019 at 13:26
  • I'm trying to solve a problem without using apex. If there is no possibility through other tools, I will probably write trigger
    – Jacob K
    Commented Jan 28, 2019 at 13:33
  • You are getting the error because your flow has reached the SOQL governor limit. Most likely because you are doing a Record Lookup inside a Loop. My advice would be to pre fetch all the Share's for the contracts, and then lookup against the pre fetched data. I am not 100% how you'd do that with Flow, because I write everything in Apex. Most likely do a bulk query and store data into a collection variable...
    – Robs
    Commented Jan 28, 2019 at 13:52

1 Answer 1

0

A) make sure your lookups are as filtered as possible, to get the fewest number of records

B) you can add a "counter" and throw a wait element when you get close to 100 queries, but that is pretty ugly, as it will introduce a delay in the processing. And it's just ugly. That said in spring 19 it looks like it's gonna be possible to set a wait time of 0, so perhaps could work.

Overall the query binding to get all the shares of all the contracts from the lookup is only possible in Apex. It can still be worth building an invocable apex method that can return the share records to the flow, and do the rest in the flow.

You must log in to answer this question.

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