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
FilikinFilikin 

See date note added in Notes and attachments view all

hi, is it possible to configure the Notes and Attachments, View All page to display the date a note or attachment was created? If not, has anyone got an example Visualforce page that lists the Notes and Attachments that I could customise? thanks.
Best Answer chosen by Admin (Salesforce Developers) 
jhurstjhurst

Filikin,

 

You would have to create your own VF page.

 

An example would be like:

 

VF Page:

 

<apex:page standardController="Account" extensions="naaRelatedList">
    <apex:detail relatedList="false"/> 
    <apex:form >
        <apex:pageBlock id="thePageBlock" title="Notes and Attachments">
            <apex:commandButton title="New" value="New Note" action="{!NewNote}"/>
            <apex:commandButton title="New" value="New Attachment" action="{!NewAttachment}"/>
            <apex:pageBlockTable value="{!AccountNotes}" var="n" >
                <apex:column headerValue="Title"><apex:outputLink value="/{!n.id}" id="theLink">{!n.Title}</apex:outputLink></apex:column>
                <apex:column headerValue="Created By" value="{!n.CreatedBy.Name}"/>
                <apex:column headerValue="Created Date" value="{!n.CreatedDate}"/>
                <apex:column headerValue="IsPrivate" value="{!n.IsPrivate}"/>
            </apex:pageBlockTable>
            <apex:pageBlockTable value="{!AccountAttachments}" var="a" >
                <apex:column headerValue="Name"><apex:outputLink value="/{!a.id}" id="theLink">{!a.Name}</apex:outputLink></apex:column>
                <apex:column headerValue="Created By" value="{!a.CreatedBy.Name}"/>
                <apex:column headerValue="Created Date" value="{!a.CreatedDate}"/>
                <apex:column headerValue="IsPrivate" value="{!a.IsPrivate}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Class:

public class naaRelatedList {

    public List<Note> notes = new Note[]{};
    public List<Attachment> attachments = new Attachment[]{};
    public Account a = new Account();
    
    public naaRelatedList(ApexPages.StandardController controller) {
        notes = [SELECT IsPrivate,CreatedBy.Name,CreatedDate,Title FROM Note where ParentId = :System.currentPageReference().getParameters().get('id') ];
        attachments = [SELECT CreatedBy.Name,CreatedDate,Id,IsPrivate, Name FROM Attachment where ParentId = :System.currentPageReference().getParameters().get('id') ];
        Account a = [select id, Name from account where id = :System.currentPageReference().getParameters().get('id')];
    }
    
    public List<Note> getAccountNotes() {
        return notes;
    }
    
    public PageReference newNote() {
        PageReference newNote = new PageReference('/002/e?parent_id=' + a.id + '&retURL=%2F' + a.id);
        return newNote;
    }
    
        public List<Attachment> getAccountAttachments() {
        return attachments;
    }
    
    public PageReference newAttachment() {
        PageReference newNote = new PageReference('/p/attach/NoteAttach?pid=' + a.id + '&parentname=' + a.Name + '&retURL=%2F' + a.id);
        return newNote;
    }

}

 Hope this helps

Jay

 

All Answers

jhurstjhurst

Filikin,

 

You would have to create your own VF page.

 

An example would be like:

 

VF Page:

 

<apex:page standardController="Account" extensions="naaRelatedList">
    <apex:detail relatedList="false"/> 
    <apex:form >
        <apex:pageBlock id="thePageBlock" title="Notes and Attachments">
            <apex:commandButton title="New" value="New Note" action="{!NewNote}"/>
            <apex:commandButton title="New" value="New Attachment" action="{!NewAttachment}"/>
            <apex:pageBlockTable value="{!AccountNotes}" var="n" >
                <apex:column headerValue="Title"><apex:outputLink value="/{!n.id}" id="theLink">{!n.Title}</apex:outputLink></apex:column>
                <apex:column headerValue="Created By" value="{!n.CreatedBy.Name}"/>
                <apex:column headerValue="Created Date" value="{!n.CreatedDate}"/>
                <apex:column headerValue="IsPrivate" value="{!n.IsPrivate}"/>
            </apex:pageBlockTable>
            <apex:pageBlockTable value="{!AccountAttachments}" var="a" >
                <apex:column headerValue="Name"><apex:outputLink value="/{!a.id}" id="theLink">{!a.Name}</apex:outputLink></apex:column>
                <apex:column headerValue="Created By" value="{!a.CreatedBy.Name}"/>
                <apex:column headerValue="Created Date" value="{!a.CreatedDate}"/>
                <apex:column headerValue="IsPrivate" value="{!a.IsPrivate}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Class:

public class naaRelatedList {

    public List<Note> notes = new Note[]{};
    public List<Attachment> attachments = new Attachment[]{};
    public Account a = new Account();
    
    public naaRelatedList(ApexPages.StandardController controller) {
        notes = [SELECT IsPrivate,CreatedBy.Name,CreatedDate,Title FROM Note where ParentId = :System.currentPageReference().getParameters().get('id') ];
        attachments = [SELECT CreatedBy.Name,CreatedDate,Id,IsPrivate, Name FROM Attachment where ParentId = :System.currentPageReference().getParameters().get('id') ];
        Account a = [select id, Name from account where id = :System.currentPageReference().getParameters().get('id')];
    }
    
    public List<Note> getAccountNotes() {
        return notes;
    }
    
    public PageReference newNote() {
        PageReference newNote = new PageReference('/002/e?parent_id=' + a.id + '&retURL=%2F' + a.id);
        return newNote;
    }
    
        public List<Attachment> getAccountAttachments() {
        return attachments;
    }
    
    public PageReference newAttachment() {
        PageReference newNote = new PageReference('/p/attach/NoteAttach?pid=' + a.id + '&parentname=' + a.Name + '&retURL=%2F' + a.id);
        return newNote;
    }

}

 Hope this helps

Jay

 

This was selected as the best answer
FilikinFilikin

thanks Jay, I changed the "New Note" to use the 15 character ID and it works perfectly.

 

public PageReference newNote()
    {
        // remove 3 chars from con.id
        String shortID = con.id;
        shortID = shortID.substring(0,15);
        PageReference newNote = new PageReference('/002/e?parent_id=' + shortID + '&retURL=%2F' + con.id);
        
        return newNote;
    }