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
Brandon Barb 4Brandon Barb 4 

Custom Related Files Component

I have a component and apex controller that calls/displays all the related files on a record.
 
How can I filter the returned files by a field that is set on ContentVersion?
 
ie. only show files if Document_Type__c = Supporting Document
 
 
Apex controller: 
 
    public class SimplyfyFilesCntrl {  
       @AuraEnabled  
       public static List<ContentDocument> getFiles(string recordId){ 
         List<ContentDocument> DocumentList = new List<ContentDocument>(); 
         Set<Id> documentIds = new Set<Id>();  //store file ids
         List<ContentDocumentLink> cdl=[select id,LinkedEntityId,ContentDocumentId from ContentDocumentLink where LinkedEntityId=:recordId]; 
         for(ContentDocumentLink cdLink:cdl){  
           documentIds.add(cdLink.ContentDocumentId);  // Document ids
         }      
         DocumentList = [select Id,Title,FileType,ContentSize from ContentDocument where id IN: documentIds]; 
         return DocumentList;  
       }  
      
     }