Created
July 8, 2018 14:54
-
-
Save SalesforceBobLightning/6ec46247cec0208df439e1d743d72d0c to your computer and use it in GitHub Desktop.
Get Custom Object Related Files using Salesforce Apex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Set<Id> getFiles(Id recordId) { | |
| List<ContentDocumentLink> files = [SELECT ContentDocumentId | |
| FROM ContentDocumentLink | |
| WHERE LinkedEntityId IN ( SELECT Id FROM CUSTOM_OBJECT_NAME__c ) | |
| AND LinkedEntity.Type='CUSTOM_OBJECT_NAME__c' | |
| AND LinkedEntityId = :recordId]; | |
| if (files.size() > 0) { | |
| return (new Map<Id, ContentDocumentLink>(files)).keySet(); | |
| } | |
| return new Set<Id>(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment