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
Rana RoyRana Roy 

Record display on VF Page

Hi Experts, I am a beginner. Please help me to do the following.
I have to Create a VF Page to display the related Contacts of the Related Account of an Opportunity. It should be displayed on each opportunity page.
Any help will be appreciated
Kiran RKiran R
Hey Rana,

You could something similar like this:

VF Page:
<apex:page standardController="Opportunity" extensions="sample1" >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!acct}" var="a">
            <apex:column value="{!a.Name}"/>
            <apex:repeat value="{!a.Contacts}" var="c">
                <apex:column value="{!c.Name}"/>
            </apex:repeat>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Your controller would be a simple query that gets the Contact from the Account id listed on the oppty. Similar to the following:
public class sample1
{    
     public FundRequest_Edit(ApexPages.StandardController controller) {
        this.controller = controller;
    }
    
    public ApexPages.StandardController controller {
        set;
        get;
    }
    
    public List<Account> acct {get;set;}
    public sample1()
    {
        acct = [SELECT Name, (SELECT Name, Email FROM Contacts) FROM Account Where id = Opp.Account];
    }    
}

 
Rana RoyRana Roy
Thanks for your reply.
It is showing the following error:
Error: Compile Error: Invalid constructor name: FundRequest_Edit at line 3 column 13
 
Rana RoyRana Roy
Thanks for your help Rakesh. It is now showing another error :(
Error: Compile Error: expecting a colon, found 'Opp.Account' at line 15 column 88

Can you please correct this or give an alternate solution?
Rana RoyRana Roy
I am a Salesforce beginner friend. Trying to understand the things, not copy, cut, paste.
Thanks for your help
Kiran RKiran R
@Rakesh, That is just a sudo code. You can't hand over the code wirting it line by line. Its simply not possible and i am sure this forum's intentions are not so as well.

So, Do not expect the code suggestions given by others are implemented tested and deployment -ready. Again, Its just an idea/ pattern. If you do not like the solution, You can propose a new one. Don;t need to criticize the help.

 
Rakesh51Rakesh51
@Kiran :- Sorry if i hurt you. My personal thought providing sudo code is not a big deal isntead of helping someone without explaning or any additonal commnet.
Rana RoyRana Roy

I have tried, but still not able to do.
Can I get any more help?