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
JonReevesJonReeves 

SOQL Parent-Child Help

Hey I still struggling writing a Parent-Child query for the Content object...

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_erd_content.htm#sforce_api_erd_content

 

I'm trying to Return the ContentVersion Fields WHERE its Parent (ContentDocument) is in a particular Workspace...

I belive I need to access 3 tables.. ContentWorkspaceDoc, ContentDocument, ContentVersion. But I cannot seem to form a working SOQL that accesses these tables in one query. Can anyone help?

 

I consistently get an error: Didn't understand relationship 'ContentWorkspaceDoc'

 

When I look up the object it doesn't note a relationship name for the Joins, but the Diagram I posted above clearly shows there is a relationship.

JonReevesJonReeves

SELECT Id, Title, ContentUrl, (SELECT ContentDocument.ContentWorkspaceDoc.Id FROM ContentDocument.ContentWorkspaceDoc WHERE ContentDocument.ContentWorkspace.Id = '05830000000TgTD') FROM ContentVersion WHERE PublishStatus = 'P' AND isLatest = true AND IsDeleted = false

 

Highlighted above is the bit I can't figure how to include.... I'm aware that ContentDocument Stands between Workspace and Version, but I can't figure the relationship notation.

JonReevesJonReeves

Managed to get this working....

SELECT Id, ContentDocument.LatestPublishedVersion.Title, ContentDocument.LatestPublishedVersion.ContentUrl FROM ContentWorkspaceDoc WHERE ContentWorkspace.Id = '05830000000TgTD' AND ContentDocument.LatestPublishedVersion.PublishStatus = 'P' AND ContentDocument.LatestPublishedVersion.isLatest = true AND ContentDocument.LatestPublishedVersion.IsDeleted = false

 Trying to figure out how to use that relationship for SEARCH (SOSL) instead of SOQL now.