A handful of our users have created notes on contact and opportunity objects that we are trying to port over. They are currently saved as ContentDocuments - but I also want to pull what objects the notes are related to via contentdocumentlink.
Here's where things get weird.
When I run the following query:
SELECT title, filetype from contentdocument
I get 50 results.
However, when I run a query for contentdocumentlink:
SELECT
contentdocument.title,
linkedentity.id,
contentdocument.id
FROM ContentDocumentLink
WHERE linkedentityid in (SELECT id FROM Contact)
//inner query required, can't SOQL query ContentDocumentLink
//without specifying a linkedentityid...
and then place all of the contentdocument id's into a set,
set<id> docIds = new set<id>();
for(contentdocumentlink cdl : [*above query*]){
docIds.add(cdl.documentid);
}
I get hundreds of results.
So a full query of contentdocument gets 50 results, but a full query of contentdocumentlink returns hundreds of contentdocument ids...
Manually checking the contentdocument id's shows that the contentdocuments do exist, they just don't show up in the general query.
A final detail that may be important is the file type of these contentdocuments that are not showing up.
When I query
SELECT title, filetype from contentdocument
The file types are XLS, DOC, PDF, etc.
But when I manually input a doc id I grabbed from contentdocumentlink (that does not show up in the general contendocument query),
SELECT title, filetype from contentdocument where id = :my_file.id
I get a hit with a file type of SNOTE
Is there something funky with SNotes that make them not show up in general queries? Why would there by contentdocument id's that show up from contentdocumentlink, but not from a general query of contentdocument?