I'm trying to retrieve some ContentVersion records, but I'm having a lot of issues with it. After some research it seems as if the records are divided into two 'sets' as it were, and Salesforce in most cases refuses to return records from one of the sets. What's going on?! This might sound vague, but please read on.
Example 1
For example, when I query for two records, one from 'set A' and one from 'set B' like this:
SELECT Id FROM ContentVersion WHERE Id IN ('068C0000002LRddIAG','068C000000180RyIAI')
I get the 2 records, as expected. However, when I try
SELECT Id FROM ContentVersion WHERE Id = '068C0000002LRddIAG' OR Id = '068C000000180RyIAI'
I get only 1 record, which is completely odd! If I query them individually by Id, I do get them returned, so they certainly exist. Does somebody have a clue what's going on?
Example 2
More oddness. I only get the ContentVersions from set B returned when I query by Id, but not otherwise. If I do this:
SELECT Id FROM ContentVersion WHERE Title = 'UniqueTitle'
I get 0 results. However, when I make the query more strict by adding an Id clause:
SELECT Id FROM ContentVersion WHERE Title = 'UniqueTitle' AND Id = '068C0000002LRddIAG'
I do get the 1 record as result. In other words: if I don't literally query by Id, I don't get any results whatsoever from the second set of records.
Research
A pointer might be that the two sets are like this, as far as I can see:
- set A: ContentVersion records that are uploaded through the UI
- set B: ContentVersion records that were created when I uploaded FeedItem records through the API (type = 'ContentPost' with ContentData filled with a Base64 encoded blob)
Somehow, the latter did create a structure of FeedItem, FeedAttachment, ContentDocument and ContentVersion, but they almost never get returned in SOQL searches, except if I mention the Id of the ContentVersion explicitly, and even then not in all cases (e.g. above example where I mix records from set A and set B).
Anybody?