• Surya Killedar
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
*Controller Class

public class ConOpptyRelatedToAccount 
{
     public ConOpptyRelatedToAccount(ApexPages.StandardController controller)
        {
        }
     public List<Contact> getContacts() 
    {
        
        List<Contact> con = [SELECT Id, FirstName, LastName, Title, Email FROM Contact WHERE AccountId=:apexpages.currentpage().getparameters().get('id')];
        return con;
    }
    
    public List<Opportunity> getOpportunities() 
    {
        
        List<Opportunity> Oppty = [SELECT Id, CloseDate, Amount, StageName, Name FROM Opportunity WHERE AccountId=:apexpages.currentpage().getparameters().get('id')];
        return Oppty;
    }
    
    public pagereference downLoad(){
        pagereference p = new pagereference('/apex/PDFofRelatedList');
        return p;
    }
  
}

******************************************************************************
*Vf page
<apex:page standardController="Account"  extensions="ConOpptyRelatedToAccount"  >
    <apex:form >
        
        <apex:pageBlock title="Contacts List" >
            
            <apex:pageBlockTable value="{!contacts }" var="Con">
                <apex:column value="{!Con.FirstName }"/>
                <apex:column value="{!Con.LastName }"/>
                <apex:column value="{!Con.Title }"/>
                <apex:column value="{!Con.Email }"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
        
        <apex:pageBlock title="Opportunity List" >
            <apex:pageBlockTable value="{!opportunities }" var="op">
                <apex:column value="{!op.Name }"/>
                <apex:column value="{!op.CloseDate }"/>
                <apex:column value="{!op.StageName }"/>
                <apex:column value="{!op.Amount }"/>
            </apex:pageBlockTable>
            
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton value="Download Pdf" action="{!downLoad}" />
            </apex:pageBlockButtons>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>
*Controller Class

public class ConOpptyRelatedToAccount 
{
     public ConOpptyRelatedToAccount(ApexPages.StandardController controller)
        {
        }
     public List<Contact> getContacts() 
    {
        
        List<Contact> con = [SELECT Id, FirstName, LastName, Title, Email FROM Contact WHERE AccountId=:apexpages.currentpage().getparameters().get('id')];
        return con;
    }
    
    public List<Opportunity> getOpportunities() 
    {
        
        List<Opportunity> Oppty = [SELECT Id, CloseDate, Amount, StageName, Name FROM Opportunity WHERE AccountId=:apexpages.currentpage().getparameters().get('id')];
        return Oppty;
    }
    
    public pagereference downLoad(){
        pagereference p = new pagereference('/apex/PDFofRelatedList');
        return p;
    }
  
}

******************************************************************************
*Vf page
<apex:page standardController="Account"  extensions="ConOpptyRelatedToAccount"  >
    <apex:form >
        
        <apex:pageBlock title="Contacts List" >
            
            <apex:pageBlockTable value="{!contacts }" var="Con">
                <apex:column value="{!Con.FirstName }"/>
                <apex:column value="{!Con.LastName }"/>
                <apex:column value="{!Con.Title }"/>
                <apex:column value="{!Con.Email }"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
        
        <apex:pageBlock title="Opportunity List" >
            <apex:pageBlockTable value="{!opportunities }" var="op">
                <apex:column value="{!op.Name }"/>
                <apex:column value="{!op.CloseDate }"/>
                <apex:column value="{!op.StageName }"/>
                <apex:column value="{!op.Amount }"/>
            </apex:pageBlockTable>
            
            <apex:pageBlockButtons location="Bottom">
                <apex:commandButton value="Download Pdf" action="{!downLoad}" />
            </apex:pageBlockButtons>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>