Apologies in advance for the quality of my code :-)I am not a developer so my skill is limited. I am trying to render a VF page on our case console app which would display all attachments for all emails associated to a case. I thought that I would be able to take an example and tweak it but seems no one else is doing this so I tried from scratch. I need to somehow get the case Id in the controller I tried using the standard controller but not sure if that is correct approach.
Controller:-
Public Class AttachmentController
{
public AttachmentController(ApexPages.StandardController controller) {
}
Public List<Attachment> GetAttachments(ApexPages.StandardController controller)
{
string casId = controller.getRecord().Id;
List<Attachment> attachedFiles = [SELECT Name, Body, ContentType, parentId FROM Attachment WHERE ParentId IN (SELECT Id FROM EmailMessage WHERE ParentId =:casId)];
if( attachedFiles != null)
{
return attachedFiles;
}
return attachedFiles;
}
}
VF:-
<apex:page Controller="AttachmentController">
<apex:repeat var="att" value="{!attachedFiles}">
<apex:outputLink value="/{!att.Id}" target="_blank">View File</apex:outputLink>
</apex:repeat>
</apex:page>
Any help would be greatly appreciated