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??
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; } }
<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="https://cs5.salesforce.com/{!a.ParentId}" target="_blank"> {!a.ParentId} /*Here m getting that account id but i want account name */ </apex:outputLink>
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 />
<head>
</head>
<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="https://cs5.salesforce.com/{!a.ParentId}" target="_blank">
{!a.ParentId} /*Here m getting that account id but i want account name */
</apex:outputLink>
</apex:column>
<apex:column headerValue="Last Modified Date" value="{!a.LastModifiedDate}"></apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:outputPanel>
</div>
</apex:page>