My request is simple our client wants to have a link that opens/downloads files in a view.

The object has Notes and Attachments and I can add files to it no problem.

The idea I have with my primitive understanding of the framework is to make inside my Field Set a reference to the files inside Notes and Attachments by ID and visibly by the name associated with the attachment.

How would I go about making the Notes and Attachments visible in the Field Set? Is a Field Set the right way to do this?

The client wants to view many records at once. A nice way would be to give them access to get the associated files of many records in the existing list view. Optimally a hover to get a preview window would be great. . .

This must be a well known and previously solved problem.

Would I need to code a custom method inside the Field Set Controller to retrieve the Notes and Attachments? Or is there a handy wizard to do this? Or something else?

  • 1
    No, Field Set is definitely not the right tool, if you are trying to define which records to display and which not. It just creates an ordered collection of fields, and tells you nothing about individual records. Or do they just want to view all the records? If not, what are the criteria?
    – Adrian Larson
    Commented Sep 30, 2016 at 13:25
  • They want to view all the records. Criteria is as I understand it to review a large set of records quickly. They do not want all the data just a filtered list of data relevant for this specific piece of the business process. Occasionally they will want details in these files.
    – JPK
    Commented Sep 30, 2016 at 13:54
  • 1
    Ah, I misunderstood what you're going for. It's much simpler to use <apex:relatedList>. Does that not suit your needs?
    – Adrian Larson
    Commented Sep 30, 2016 at 14:50
  • No unfortunately not. Think an excel sheet with an extra column on the right for attachments. Its a custom controller on a custom object. I've gotten the notes and attachments column to append properly for one ID. Next I need to get it to work for the actual IDs but I dont have this part solved yet.
    – JPK
    Commented Oct 4, 2016 at 10:18

1 Answer 1


Heres a followup: Instead of trying to reference the IDs from the page it was much easier to add the attachments to the custom object itself using a wrapper class. This made the IDs available in the object itself

public class Records {
        public sObject obj {get; set;}
        public List<Attachment> attachments {get {
            List<Attachment> objAttachments = new List<Attachment>();       
                objAttachments = [Select Id, Name, ContentType from Attachment where ParentId = :obj.Id];                                       
            catch(exception ex)
                objAttachments = null;
            return objAttachments;  
        } set;}

    //Get all records
    public List<Records> getRecords() 
        List<Records> records = new List<Records>();
        for (sObject obj : ssc.getRecords()) {
            Records record = new Records();
            record.obj = obj;
        return records;


        <apex:column headervalue="Attachments">
            <apex:repeat value="{!item.attachments}" var="image">
                <apex:outputlink value="/servlet/servlet.FileDownload?file={!image.Id}">"{!image.Name}"</apex:outputlink>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .