There is already a related question Nested SOQL Query in a Flow. However it is unanswered and out of date, from more than 7 years ago.

With all of the new capabilities of flows, I want to know if there is any way of doing something like SELECT Id, (Select FirstName FROM Contacts) FROM Account, like an inner query or nesed SOQL, with the Get Records element of a flow.


2 Answers 2


You can use the Loop element in the flow to loop through all Contacts in the account, get the Firts Name, store all first names in a variable. Here is more about loops: https://www.salesforceben.com/salesforce-flow-loops-best-practices-and-examples/#:~:text=A%20Loop%20is%20a%20Salesforce%20Flow%20element%20that,which%20you%20want%20to%20either%20assess%20or%20action.


There is not something out of the box that will make this a clean implementation. I would not suggest a query within a loop as you will hit the SOQL limit fairly question.

You can do 2 separate queries and then loop through each one to create a new collection of the data that you need.

Here is a custom component made by UnofficialSF that seems to solve the problem you are encountering: https://unofficialsf.com/automate-junction-updates-with-getchildcollection-and-getlookupcollection/

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.