0

I trying to get all files associated with a record. I tried query but not sure is it correct?

SELECT Id,ParentId,Title FROM ContentDocument WHERE ParentId = '<recordID>'
  • I got the solution. I corrected my query SELECT Id, LinkedEntityId, ContentDocumentId, Visibility, IsDeleted, ShareType, ContentDocument.Title, ContentDocument.createdDate, ContentDocument.FileType FROM ContentDocumentLink WHERE LinkedEntityId = '<recordID>' – nalasup Jan 4 '18 at 6:13
  • Hi, and welcome to SFSE! you can click the Answer button (below) to add an actual answer. Comments are not the appropriate place for an answer. – sfdcfox Jan 4 '18 at 6:14
0

Try this

Map<id,ContentDocumentLink> CDLMap = New Map<id,ContentDocumentLink>([SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId =: <recordID>]);
List<ContentVersion> Docs = [SELECT ContentDocumentId,ContentSize,CreatedDate,Title FROM ContentVersion WHERE ContentDocumentId IN : CDLMap.keyset()];
0

I got the solution. I corrected my query

[SELECT Id, LinkedEntityId, ContentDocumentId, Visibility, IsDeleted, ShareType,
ContentDocument.Title, ContentDocument.createdDate, ContentDocument.FileType
FROM ContentDocumentLink 
WHERE LinkedEntityId = '<recordID>'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.