function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Need helo to retrieve related contents of Opportunity



Is there any way to retrieve related contents of any opportunity via SOQL?

Scenario: I have attacted two contents to an Opportunity using related Content List on an Opportunity Object. I want to retrieve the ids of those two contents via SOQL for that Opportunity.



select Opportunity__c from Content__c where Opportunity__c = :THIS_OPPORTUNITY_ID


If you might have noticed, Opportunity and CRM Content both are standard objects.


Never used Content.


What is your question?


Just looked at the schema.


There is a reference in ContentVersion called FirstPublishLocationId to every available object including opportunity.


There is then a reference in ContentDocumentFeed called RelatedRecordId to ConentVersion.


Could you get to the Content this way?


Yes I tried in this way but FirstPublishLocationId is empty for each record in ContentVersion.