We have a set of ContentVersion
records that have been inserted by users via a FeedItem
post. Unfortunately because Chatter groups has many functional limitations we have to migrate these files to regular ContentWorkspace
.
However, because the files were inserted via an individual FeedItem
, when we attempted to select them programmatically to get their ContentDocumentId
for a new ContentDocumentLink
they are not being returned even for System Administrator
:
Example:
System.debug(LoggingLevel.Warn,'FeedItems: '+[SELECT COUNT() FROM FeedItem WHERE Type='ContentPost' AND CreatedDate >= :startDate AND CreatedDate <= :endDate AND IsDeleted=false]);
Returns 2000+ records...
Set<Id> cdIds = new Set<Id>();
List<ContentDocumentLink> cdls = new List<ContentDocumentLink>();
for(ContentVersion cv : [SELECT ContentDocumentId FROM ContentVersion
WHERE IsLatest=true AND Id IN
(SELECT RelatedRecordId FROM FeedItem WHERE Type='ContentPost' AND CreatedDate >= :startDate AND CreatedDate <= :endDate AND IsDeleted=false)]){
// no records returned
}
Returns no records...
If I manually share the record to a library (via the UI), and than select the FeedItem
directly, I can now see the ContentDocumentId
?