1

I have created a scheduled flow to update parent account on accounts based on a criteria but there is SOQL 101 error since trying to query the parent account inside the loop not sure how to resolve this and pull the related record for each account without looping

enter image description here

2
  • Why not just make this a Record-Triggered Flow instead?
    – sfdcfox
    Dec 1, 2021 at 18:55
  • since we cant control the sequence of insertion like parent and child records Dec 1, 2021 at 18:59

1 Answer 1

2

Short Answer: You can't do this in a Flow.

Longer Answer: There's no such mechanism available in Flows like Apex's Map object. So, you're limited to two choices: query inside a loop, or pull out the Id values for the parents (one loop), then get those accounts, then use a nested loop to find the appropriate parent for each child. This has potentially multiplicative growth, meaning it will likely exceed either CPU limits or the 2,000 executed elements per Flow limit (as few as 65 child records could hit this limit).

You'll need some Apex code to make it efficient enough to work with the limits of Flows, and by the time you've written enough Apex to do this, you may as well just make it a Schedulable Apex class and skip the Flow parts.

You must log in to answer this question.

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