3

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

4
  • 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
    Commented Mar 25, 2021 at 19:02
  • which flow action did you have in mind for this? Commented Mar 26, 2021 at 15:08
  • FilterCollection
    – cropredy
    Commented Mar 26, 2021 at 15:39
  • You are right that a GET in a Loop like this is bad practice and we often find ourselves needing to build apex or install tools such as the one suggested from UnofficialSF. On occasion, though, we may find a clever way out, but it depends on the details. Could you update your question with the answer to the following questions? You mention the Assignment records have a "Resource" field that you're using to find the Contact. Is that "Resource" field a lookup to Contact? And which email action is that you are using at the end?
    – Jeff Kranz
    Commented Nov 12, 2021 at 6:26

1 Answer 1

0

THE loop in the flow is working as for each loop and you must not add get element inside loop

Take one collection and add your ids to that collection and than fetch the record

1
  • 2
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Nov 12, 2021 at 5:10

You must log in to answer this question.

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