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 

Content Library and Public Groups

I've got one main objective:

To Return all Content Documents (latest version) which the user should have access to (based on the Public Group assignment to a Library).

 

Any ideas how these tables co-exist and what method would you use to achieve the end result.

 

I could hardcode a list of Library IDs and try and build a relational SOQL which would only bring back DocumentVersions in those Libraries, kinda like...:

SELECT
	ContentVersion.Id, ContentVersion.Title
FROM
	ContentVersion
WHERE
	ContentDocument.id = ContentVersion.ContentDocumentId
	AND
		ContentWorkspaceDoc.ContentDocumentId = ContentDocument.Id
	AND
		(ContentWorkspaceDoc.ContentWorkspaceId = 1
		OR ContentWorkspaceDoc.ContentWorkspaceId = 2
		OR ContentWorkspaceDoc.ContentWorkspaceId = 3)
GROUP BY
	ContentVersion.Id

 

but I'd rather beable to fetch dynamically based on which libraries we give the user access to (via Public Groups). I can't however find how Public Groups and Libraries relate (Groups and ContentWorkspaces).

 

Any ideas?

JonReevesJonReeves

while I'm on this SOQL topic, anyone know why I can't seem to do a Parent - Child query but I can do a Child - Parent query?

 

i.e.. this works:

SELECT Id, ContentDocument.id FROM ContentWorkspaceDoc

but this doesn't:

SELECT Id, Title, (SELECT Id FROM ContentWorkspaceDoc) FROM ContentDocument

 

I'm sure its probably a syntax thing.