We have 3 objects.
- OS_Account_Document__c (Custom)
- ContentDocument
- ContentDocumentLink
I need to query two custom fields (Document_Type__c and Custom_Document_Description__c) from the Custom Object OS_Account_Document__c
and three Standard fields (Id, Title, ContentSize) from ContentDocument
.
The Id of the Custom Object is stored in the LinkedEntityId field of ContentDocumentLink. ContentDocumentLink also has a ContentDocumentId field which stores Id of the ContentDocument.
So, for every custom object record, I need to have Document_Type__c and Custom_Document_Description__c (Custom object fields) and it's corresponding Title, ContentSize and Id (from ContentDocument object) in one SOQL query.
I tried something like this but it didn't work.
SELECT Id, Title, ContentSize FROM ContentDocument WHERE Id in
(SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId in
(SELECT Id FROM OS_Account_Document__c where Account__c='0015B00000fSGQ3QAO'))