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
Ananthanarayanan NemmaraAnanthanarayanan Nemmara 

Visualforce page fetching orders

Hi All,
I am new to the salesforce development world.I want to fetch few columns feilds from opportunity table and display it in account page related to the account. I realized that I would need to make a visualforce page for this and wrote the below code. I am working on salesforce lightning and cannot see the vf page to be added to my account page layout. Both the apex class and VF page are saved without error but cannot see the VF page in my VF page to add in page layout.
Please let me know if something is wrong:
Apex class:
public class RelatedOrdersController
{
 public   List<Opportunity>  oppList1 { get; set; }
 public static List<Opportunity> getOpen1(List<Opportunity> count)
    {
    id recId = Apexpages.currentpage().getparameters().get('id');
        Integer lim = count.size() + 25;
     List<Opportunity> oppList1 = [SELECT Order_Number__c FROM Opportunity WHERE RecordTypeId =: '012f40000005QP8' AND AccountId =: recId ORDER BY Order_Date__c DESC Limit :lim];
        return oppList1;
    }
}
VF page:
<apex:page controller="RelatedOrdersController">
<apex:pageBlock >
<apex:pageblockTable value="{!oppList1}" var="cl">
<apex:column value="{!cl.Order_Number__c}"/>
<apex:column value="{!cl.Order_Invoice_Type__c}"/>
<apex:column value="{!cl.Type}"/> </apex:pageblockTable>
</apex:pageBlock>
</apex:page>
Raj VakatiRaj Vakati
Here is the sample code.Modify the SOQL query in the controller and add conditions.
Go to the visual force page and check the checkbox  "Available for Lightning Experience, Lightning Communities, and the mobile app " to show on lightning .



 
public class RelatedOrdersController
{
    Private String recId{get;set;}
    public RelatedOrdersController(ApexPages.StandardController sc){
        recId = Apexpages.currentpage().getparameters().get('id');
    }
    public  List<Opportunity> getOpps()
    {
        List<Opportunity> oppList1 = [SELECT Name FROM Opportunity 
                                      where AccountId =: recId ];
        return oppList1;
    }
}
<apex:page standardController="Account" extensions="RelatedOrdersController">
    <apex:pageBlock >
        <apex:pageblockTable value="{!Opps}" var="cl">
            <apex:column value="{!cl.Name}"/>
            
        </apex:pageblockTable>
    </apex:pageBlock>
</apex:page>

 
Ananthanarayanan NemmaraAnanthanarayanan Nemmara
Hi Raj,
Thanks for your response. I tried using the sample code that you provided but could you please let me know what is in the value field of apex:pageblockTable. I want to display opportunity feilds on account page.

Regards