0

To keep it simple, I want to know to which Objects are linked my Attachments, so I executed the following SOQL query :

select count(id), Parent.type counter from Attachment
 
group by Parent.type

I get the result I want with the count for each object.

My problem now is I want to do the Same for ContentDocument/ContentVersion I know to do it for a specific object I would do :

SELECT Id, LinkedEntityId, ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId IN (SELECT Id FROM Account)

And I will get the count for Account. Thing is I want to know for all objects because my goal is to know how many Document are linkes to each object and have an overview, so I cannot list myself each objects in salesforce to find it. Is there a way to do that in one go ? This would not work : SELECT Id, LinkedEntityId, ContentDocumentId FROM ContentDocumentLink

Because I get Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Id's using the IN operator.

Maybe with APEX ?


Edit : The QueryAll document followed with this query did the trick :

SELECT COUNT(Id), LinkedEntity.type
FROM ContentDocumentLink
GROUP BY LinkedEntity.type

1 Answer 1

0

You won't be able to query this directly from Salesforce. However, you can enable the Query All Files permission, query all the metadata to your local device, then use Excel, MySQL, etc to analyze the data.

1
  • Thank you, I think this will do with a bit of work.
    – Art
    Jan 10 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .