Hello,
We're trying to run a SOQL query to collect grandchild records for Excel row replication.
Our objects are Account > Opportunities > Opportunity Products (Opportunity Line Items)
In this case, we want to collect all Opportunity Products (Opportunity Line Items) from all Opportunities for a given Account, and using Row replication extract the data into an Excel file.
We are trying this SOQL query:
SELECT Product2Id FROM OpportunityLineItem WHERE OpportunityId in (select ID from Opportunity where AccountId ='<<Account_Id>>')
If we replace the <<Account_Id>> with a specific Account (URL) id then the above works in the developer console as desired. However, we would like to use a dynamic Account Id approach where we are running the DDP from an Account record as a starting point.
Other parameters we are using:
[Starting Object: Account]
[Repeat By: Row]
Any help is much appreciated!
Solved
SOQL query to collect grandchild records for Excel row replication: Account > Opportunity > Opp Prod
Best answer by natsu_docs
Hi,
If you're looking to pull in the grandchild object from the Account I recommend the following SOQL:
SELECT [fields] FROM OpportunityLineItem WHERE Opportunity.Account.Id='<<Account_Id>>'
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.