As the error states, you cannot specify related fields in the inner SELECT statement -- you can only specify fields that are in the object itself. There is a Product2Id field in the OpportunityLineItem object (see [documentation](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_opportunitylineitem.htm)) so you should be able to use this field: SELECT ContentDocument.Id FROM ContentDocumentLink WHERE LinkedEntityId IN (SELECT Product2Id FROM OpportunityLineItems WHERE Opportunity = '{pv0}')