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
Laytro80Laytro80 

New developer needs help on controllers

Hi,

 

Very new to developing with Visualforce.  I am trying to create a simple page most of which is using information stored on the account page.  So I began using the standard account controller.

 

I now need to display only certain fields and certain records for one section, see below. 

 

<apex:pageBlockSection title="Board Members" columns="1"> <apex:pageBlockTable value="{!account.Contact_Role__r}" var="contact"> <apex:column value="{!contact.contact__r.name}" /> <apex:column value="{!contact.title__c}"/> <apex:column value="{!contact.state__c}"/> <apex:column value="{!contact.primary_account__c}"/> 

</apex:pageBlockTable> 

 

I think I need to create an extension which I have tried but my filter (only show roles = "Board Members" does not work.  Any guidance would be much appreciated.  Full code below which probably looks bad!!!

 

<apex:page standardController="Account" extensions="cr"> <apex:sectionHeader title="Sales Plan for {!Account.Name}"/> <apex:pageBlock title="People"> <apex:pageBlockSection title="Board Members" columns="1"> <apex:pageBlockTable value="{!account.Contact_Role__r}" var="contact"> <apex:column value="{!contact.contact__r.name}" /> <apex:column value="{!contact.title__c}"/> <apex:column value="{!contact.state__c}"/> <apex:column value="{!contact.primary_account__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockSection title="Key Contacts" columns="1"> <apex:pageBlockTable value="{!account.Contact_Role__r}" var="contact"> <apex:column value="{!contact.contact__r.name}"/> <apex:column value="{!contact.contact_role__c}"/> <apex:column value="{!contact.title__c}"/> <apex:column value="{!contact.primary__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockSection title="Consultants" columns="1"> <apex:pageBlockTable value="{!account.Contact_Role__r}" var="contact"> <apex:column value="{!contact.primary_account__c}"/> <apex:column value="{!contact.contact__r.name}"/> <apex:column value="{!contact.primary__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock> <apex:pageBlockSection columns="1"> <apex:outputField value="{!Account.Last_Sales_Contact__c}"/> <apex:outputField value="{!Account.Last_Road_Show_Contact__c}"/> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock title="Filenotes/News/Updates"> <apex:pageBlockTable value="{!account.File_Notes__r}" var="filenotes"> <apex:column value="{!filenotes.Date_of_Filenote__c}"/> <apex:column value="{!filenotes.Subject__c}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Opportunities"> <apex:pageBlockTable value="{!account.opportunities}" var="Opps"> <apex:column value="{!Opps.CloseDate}"/> <apex:column value="{!Opps.Name}"/> <apex:column value="{!Opps.Description}"/> <apex:column value="{!Opps.Probability__c}"/> <apex:column value="{!Opps.Amount}"/> <apex:column value="{!Opps.NextStep}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Plan of Action"> <apex:pageBlockTable value="{!account.ActivityHistories}" var="task"> <apex:column value="{!task.activitydate}"/> <apex:column value="{!task.subject}"/> <apex:column value="{!task.Whoid}"/> <apex:column value="{!task.whatid}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Static Data"> <apex:pageBlockSection columns="1"> <apex:outputField value="{!Account.Description}"/> <apex:outputField value="{!Account.Funds_Under_Management__c}"/> <apex:outputField value="{!Account.Profile__c}"/> <apex:outputField value="{!Account.Objective__c}"/> <apex:outputField value="{!Account.Investment_Preference__c}"/> <apex:outputField value="{!Account.Role_of_PDS__c}"/> <apex:outputField value="{!Account.Consultant_Approval__c}"/> <apex:outputField value="{!Account.Points_to_Note__c}"/> </apex:pageBlockSection> </apex:pageBlock> 

</apex:page> 

Ajay111Ajay111
Remove 'extensions="cr" ' from your  code.
Laytro80Laytro80

Thanks Ajay,

 

Did not explain my requirements very well.

 

I want to show the standard account page layout with a few standard related lists using visual force.

 

I also, and this is the bit I am stuck on, I want to show a custom object (which I have created) called roles as a related list but with only records that meet a certain criteria.

 

For example I want my roles related list only to show roles ='board members'.

 

I have built the page and I can show a roles related list and the fields I want.  However the data that comes through is all the roles and I just want  = 'board members' 

 

Any pointers would be much appreciated.

 

Cheers

 

michaelforcemichaelforce

Laytro,

 

You answered your own question I think... you need an extension.  Create an apex class that extends the standard Account controller and create a Get method that will query and return only Board Members.

Laytro80Laytro80

Thanks for confirming.

 

Can anyone point me to a similar extension example, i.e how the code on the extension would look.

 

Cheers

 

Ross