A button on an opportunity should bring all salesforce files from the related products. Trying to figure out the correct query for this
What i have found so far is the query for salesforce files:
SELECT ContentDocument.id
FROM ContentDocumentLink
WHERE LinkedEntityId = '{pv0}'
And how to query products to opportunities:
How to query Products by Opportunity?
SELECT Id, Name, Account.Name,
(SELECT Quantity, UnitPrice, TotalPrice,
PricebookEntry.Name, PricebookEntry.Product2.Family FROM
OpportunityLineItems)
FROM Opportunity WHERE Id = :YourOppId
My tuition is that i should combine these two somehow:
Something like:
SELECT ContentDocument.Id FROM ContentDocumentLink WHERE LinkedEntityId IN
(SELECT PricebookEntry.Product2Id FROM OpportunityLineItems WHERE Opportunity = ‘{pv0}’)
But I get an error that
The inner select field 'PricebookEntry.Product2Id' cannot have more than one level of relationships
Any ideas how i can solve this?