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
nicksnicks 

create new "notes" visualforce page

how to create new "notes" related list using visualforce page?
as notes doesn't have option to sort it by created date. i want to create new related list same as notes
VinayVinay (Salesforce Developers) 
Hi Nicks,

Try below code.
 
<apex:page standardController="Contact" extensions="notes">
    
	<apex:pageBlock  >
        
            <apex:pageBlockTable value="{!NotesList}" var="n" >
                <apex:column headerValue="Type" >
                    <apex:outputText rendered="{!n.isnote}" >Note</apex:outputText>
                    <apex:outputText rendered="{!NOT(n.isnote)}" >Attachment</apex:outputText>
                </apex:column>
                <apex:column headerValue="Title" value="{!n.title}" />
                <apex:column headerValue="Last Modified" value="{!n.LastModifiedDate}" />
                <apex:column headerValue="Created By" value="{!n.createdby.name}" />
            </apex:pageBlockTable>
      
        
    </apex:pageBlock>    
    
</apex:page>
 
public class notes{
    
    public noteandattachment[] NotesList{get;set;}
     
    public notes(ApexPages.standardController std){
        NotesList=new noteandattachment[]{};
         string ContactID=ApexPages.currentPage().getParameters().get('id');
        if(ContactID==NULL){
            system.debug('No Id available');
        }
        else{
            contact[] CNotes=new contact[]{};
            CNotes=[Select id,(select isnote,title,lastmodifieddate,createdby.name from NotesAndAttachments)  from contact where id =:ContactID];
            for( contact c:Cnotes ){
                for(NoteAndAttachment obj:c.NotesAndAttachments ){
                    NotesList.add(obj);
                }
            }
        }
    }
}

https://www.forcetree.com/2011/02/upload-file-as-attachment-to-record.html

Please mark as Best Answer if above information was helpful.

Thanks,