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

Account Name from Notes

Hi all,
I want to show list of notes and related account names on vf page.
but notes dont have field account name.
how can i get the name of account from Notes??
you need to query it from the object and display the same to your VF page. 
m trying for it but not getting account name.can u help me.below is my controller.

Apex Controller : 

public class NotesController {
    List<Note> notelist;
    Account acct;
    public String accountname{get;private set;}
    public NotesController(ApexPages.StandardController con) {
    public List<Note> getNotes()
     //notelist =[Select Name,(SELECT Id,Title,CreatedBy.Name FROM Notes) FROM Account];
      notelist = [Select Id,Title,CreatedDate,IsPrivate,CreatedById,Body,ParentId,OwnerId,LastModifiedDate from Note order by ParentId];
      // acct = [Select id,Name from Account where id=:accid];
        return notelist;
    public Account getAccount()
        for(Note nt :notelist ){
            acct = [Select name from Account where Id=:nt.ParentId];
        return acct;

VF Page : 

<apex:page standardController="Account" extensions="NotesController" standardStylesheets="false" applyBodyTag="false">
  <apex:slds />
<div class="slds-scope">
  <apex:outputPanel >
 <apex:pageblock id="CustomList" title=""> 
  <apex:pageblocktable value="{!Notes}" var="a" styleClass="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout wk_table"> 
   <!--<apex:column headerValue="Title"  value="{!a.Name}"/>-->
  <apex:column headerValue="Title"  value="{!a.Title}"/>
 <apex:column headerValue="Body " value="{!a.Body}"/>
      <apex:column headerValue="Owner ID " value="{!a.OwnerId}"/>
 <apex:column headerValue="Action">
     <apex:outputLink value="{!a.ParentId}" target="_blank">
   {!a.ParentId} /*Here m getting that account id but i want account name */
      <apex:column headerValue="Last Modified Date" value="{!a.LastModifiedDate}"></apex:column>
what kind of relationship both object have? Can you please elaborate more your requirement?
m done.Got account name from "Notes&Attachments".but now want to fetch same data from "Notes" which is newly come by update in salesforce.
User-added image