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
Kevin Dillon 18Kevin Dillon 18 

SOQL where clause not working

I have a custom boolean field that I've added to Files that I'm now trying to use in a SOQL query to pull all Files that are linked to a specific record where this custom field is set to TRUE. Here's my SOQL query:

SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityID = 'a00f400000RaXnDAAV' AND ContentDocumentId IN (SELECT ContentDocumentId FROM ContentVersion WHERE Send_to_Angeion__c = TRUE)

What's odd is that this query: 

SELECT ContentDocumentId FROM ContentVersion WHERE Send_to_Angeion__c = TRUE

Never returns any results, even when I've marked the Send_to_Angeion__c as TRUE on some records. And even more interestingly, this query 

SELECT ContentDocumentId, Send_to_Angeion__c FROM ContentVersion WHERE ContentDocumentID = '069f400000Azta2AAB'

will return results and lists the value in the Send_to_Angeion__c as "true" Any ideas on how I can fix this? 

TIA
Abdul KhatriAbdul Khatri
Can you check if this works? Nothing different just added the boolean field in the clause to see how it behaves.
SELECT ContentDocumentId, Send_to_Angeion__c FROM ContentVersion WHERE ContentDocumentID = '069f400000Azta2AAB' AND Send_to_Angeion__c = true

Also try in your first query remove LinkedEntityID to ContentDocumentId
Mrityunjay Manhar 14Mrityunjay Manhar 14
Select ContentDocumentId, contentDocument.title from ContentDocumentLink where LinkedEntityId = '5007F000002rLQvQAM' and ContentDocumentId IN (select contentDocumentId from contentVersion where MY_Custom_Check__c = true)



Above query is working absolutely fine for me. You should check once if you are querying the right LinkedEntityID.