I am new to Lightning flow and I am running into an error. I have a list of records (for a custom object called assignment) and for each assignment record, I need to get a contact record whose id matches this assignment record's "Resource" field. Then I need to send an email to this list of contacts. The flow looks like this: enter image description here

As you can see, I have a get element inside of a loop, which is a really bad practice. I am not sure how to get rid of this get element inside a for loop situation. Can someone please help? Thank you

  • i would look at UnofficialSF which has a bunch of components that can do filtering on collections - this should let you do one query to get all Resources at once then filter them into only the resources per assignment so you can send the emails (essentially Flow actions that do what you can do with apex maps)
    – cropredy
    Mar 25 at 19:02
  • which flow action did you have in mind for this? Mar 26 at 15:08
  • FilterCollection
    – cropredy
    Mar 26 at 15:39

Sometimes putting the Get Records inside a loop is unavoidable, as it appears to be in this case. What is the volume you're dealing with? In this case, you'd want to make sure you don't do more than 100 SOQL queries per transaction.

  • How would we do it in apex? I dont feel comfortable with the get element in the loop. Mar 25 at 14:49
  • You would still need to query the contact record whose ID matches that of the Resource field on the Assignment record
    – Nikhil Rao
    May 16 at 1:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.