Solved

SOQL query to collect grandchild records for Excel row replication: Account > Opportunity > Opp Prod


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!

icon

Best answer by natsu_docs 27 June 2022, 10:56

View original

3 replies

Userlevel 1
Badge +8

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>>'

Hi @natsu_docs,


Thank you for the reply. We are still getting errors.
Consider that we are trying to replicate rows in Excel, but we have tried both in Word and Excel to research:
In Excel, we are obtaining the following error message: "An error occurred processing a Microsoft Office file. (InternalError) Include this Error Id if you contact Nintex Support: 4901128a-1a86-4100-b0a3-937feb34d532."
In Word, there is no error message but no results are returned.
We attach a screenshot with the relationship and the field tagger below.
Kind regards,
David

The proposed solution work. The second part (Excel file) was resolved by adding a second field into the line item columns as replication needs to be continuous in Excel.

Reply