You need to sign in to do that
Don't have an account?
Brandon 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;
}
}
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;
}
}