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
ShrutikaShrutika 

Hi Team, Is anyone worked on ContentDocumentLink query??


When am passing LinkedEntityId with any hardcoded incident id, then it is fetching ContentDocumentId and working

But  when passing any list / Id variable LinkedEntityId not fetches  ContentDocumentId .

 SELECT ContentDocumentId,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId =: InciId / 

SELECT ContentDocumentId,LinkedEntityId FROM ContentDocumentLink 
                           WHERE LinkedEntityId in:incidentIDList (List where inc id's are stored)
Sridhar Venkateswaralu 8Sridhar Venkateswaralu 8
Tried this on the developer console and works perfectly fine. sample code below.
List<Id> LinkedEntityIds = new List<Id>();
LinkedEntityIds.add('a052w0000020qMy');

List<ContentDocumentLink> contentDocumentLinks = [SELECT ContentDocumentId,LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityID IN:LinkedEntityIds];
system.debug('Result ==> ' + contentDocumentLinks);


 
sachinarorasfsachinarorasf
Hi Shrutika,

Please go through the following links for the ContentDocumentLink query.

https://success.salesforce.com/answers?id=9063A000000lX9nQAE
https://salesforce.stackexchange.com/questions/236861/how-do-i-join-contentdocumentlink-with-account-with-soql-query
https://salesforce.stackexchange.com/questions/76121/retrieve-all-contentdocument-ids-whose-related-contentdocumentlink-record-is-upd

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
www.sachinsf.com