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
HoneyFayeHoneyFaye 

SoQL Syntax to Find Account Plans Attached to Files on Accounts

I'm getting Unknown Error Parsing Query for the below. How can I fix it?

SELECT ContentDocumentId, LinkedEntityId
FROM ContentDocumentLink
WHERE LinkedEntityId in ( SELECT Id FROM Account
WHERE Id LIKE '001%' )
AND LinkedEntity.Type = 'Account' AND ContentDocument.Title LIKE '%Account Plan%'
Best Answer chosen by HoneyFaye
AnkaiahAnkaiah (Salesforce Developers) 
Hi Hiney,

try with below query.
SELECT ContentDocumentId, LinkedEntityId
FROM ContentDocumentLink 
WHERE LinkedEntityId IN (Select Id From Account) AND ContentDocument.Title LIKE '%Account Plan%'

If this helps please mark it as best answer.

Thanks!!​​​​​​​
 

All Answers

HoneyFayeHoneyFaye
I also need a way to show the Account Id in the results.
AnkaiahAnkaiah (Salesforce Developers) 
Hi Hiney,

try with below query.
SELECT ContentDocumentId, LinkedEntityId
FROM ContentDocumentLink 
WHERE LinkedEntityId IN (Select Id From Account) AND ContentDocument.Title LIKE '%Account Plan%'

If this helps please mark it as best answer.

Thanks!!​​​​​​​
 
This was selected as the best answer
HoneyFayeHoneyFaye
Thank you Ankaiah! That worked.  How can the query be modified to include the AccountId in the results?
HoneyFayeHoneyFaye
Please disregard my last comment.  The query worked. Thanks for your help.