Is there a way to query ContentDistribution and ContentDocument ? I'm looking to pull few fields from ContentDocument while building the ContentDistribution query.

Here is what I have done so far:

SELECT Id,Name,ContentVersionId, ContentVersion.FileType, ContentVersion.Title, ContentVersion.FileExtension,ContentDocument.Id FROM ContentDistribution

the above query throws an error due to ContentDocument.Id

Didn't understand relationship 'ContentDocument' in field path

  • Can you go through the ContentVersion? e.g. ContentVersion.ContentDocument.Title
    – Nick Cook
    Feb 23, 2021 at 3:35
  • yes I have thought about going through ContentVersion.ContentDocument.Title but how would I get the fields from ContentDistribution associated with ContentVersion?
    – Nick
    Feb 23, 2021 at 3:37

1 Answer 1


Although ContentDistribution.ContentDocumentId references a ContentDocument, there is no relationshipName to traverse. You can see this via Workbench, contrasting ContentDocumentId versus ContentVersionId.

Since ContentVersion's parent is ContentDocument, you can get ContentDocument fields as as a grandparent of ContentDistribution follows:

SELECT Id,Name,ContentVersionId, 
       ContentVersion.ContentDocument.ContentSize, // a field on ContentDocument
       ContentVersion.FileType, ContentVersion.Title, 
FROM ContentDistribution

enter image description here

  • Can a query be written FROM ContentVersion that includes fields from contentDistribution? For example: select id, description, title, contentDocument.fileType, (Select name from contentDistributions), contentDistribution.DistributionPublicUrl from contentversion
    – SeanW
    Oct 15, 2021 at 20:06
  • @SeanW - your suggestion does not work as there is no relationship name from ContentVersion to ContentDistribution
    – cropredy
    Oct 15, 2021 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.