2

Working on a PDF report using Visualforce. Earlier questions answered here (LINK) but now I'm stuck again.

I have two child objects off of Account.

  • Issue (Issue__c)
  • Filing (Filing__c)

The report runs from Issue, but needs to get the related Filing records from the related account. I've tried multiple times but I can't seem to add anything in filings or filings2 to the visualforce output.

Visualforce Page

<html>
    <head>            
    </head>

    <body>
        <p>Summary Page for Branch Analyst</p>

        <tr>
            <td>Issuer</td>
            <td>{!issue__c.Issuer_Name__r.name}</td>
            <td></td>
        </tr>
        <tr>
            <td>Par Amount</td>
            <td><apex:outputtext value="{0,number,$#,###,###}"><apex:param value="{!Issue__c.Par_Amount__c}"/></apex:outputtext></td>
            <td></td>
        </tr>
        <tr>
            <td>Issue Description</td><td>{!issue__c.Issue_Description__c}</td><td></td>
        </tr>
        <tr>
            <td>Date of Bid Sale</td>
            <td><apex:outputText value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!Issue__c.Date_of_Bid_Sale__c}"/></apex:outputText></td>
            <td></td>
        </tr>
        <tr>
            <td>Is the Issue subject to 15c2-12?</td>
            <td>{!issue__c.Is_the_Issue_subject_to_15c2_12__c}</td>
            <td></td>
        </tr>


        <tr>
            <td>Name</td>
            <td>{!Firm.name}</td>

This is where it fails

            <td>Filing Name</td>
            <td>{!Filings.name}</td>

        </tr>
    </body>
</html>

Here's the extension:

public with sharing class FICMSummaryPDFController {
    public Issue__c issue { get; private set; }
    public account firm { get; private set; }
    public List <Filing__c> filings { get; private set; }
    public List <Filing__c> filings2 { get; private set; }

    public FICMSummaryPDFController(ApexPages.StandardController controller){
        issue = (Issue__c)controller.getRecord();
        firm = [SELECT Name,(SELECT ID from FinancialFilings__r) from account where ID = :issue.issuer_name__c];
        filings = (firm.FinancialFilings__r == null) ? new List<Filing__c>() : firm.FinancialFilings__r;
        filings2 = [select id, name from filing__c where issuer__c = :issue.issuer_name__c];        
    }
}

}

Thanks in advance.

2

filings and filings2 are both list<Filing__c> - so you would need to iterate over it to get a list output.

You can't just access {!filings.Name}

If you are going to get a list of many filings, you should have a look at <apex:repeat> or <apex:pageblocktable>

Or if you just want to have the first element of the list, you could try it with

 public Filing__c filing { get; set; }

and in the constructor

 filing = filings[0];

or the same with filings2. You should also check that you have at least one record in filings and/or filings2 and filing doesn't get null. Otherwise {!filing.Name} (note singular!) will end-up in an exception.

Also it looks like you are missing the <table> tag in the markup.

0

Thank you @uweheim! After some additional review (and coffee) I ended with this, which is working, however, I would be open to additional input?

VF

<html>
    <head>
        <style type="text/css">
            @page {size: portrait; margin: .25in;}
            p {font-weight: bold; text-align: center;}
            table {width: 100%; border-collapse: collapse; page-break-inside: avoid; margin-bottom: 15px;}
            td {vertical-align: top; padding: 5px; }
            th {vertical-align: top; padding: 5px; }


        </style>
    </head>

    <body>
        <p>Summary Page for Branch Analyst</p>

        <tr>
            <td>Issuer</td>
            <td>{!issue__c.Issuer_Name__r.name}</td>
            <td></td>
        </tr>
        <tr>
            <td>Par Amount</td>
            <td><apex:outputtext value="{0,number,$#,###,###}"><apex:param value="{!Issue__c.Par_Amount__c}"/></apex:outputtext></td>
            <td></td>
        </tr>
        <tr>
            <td>Issue Description</td><td>{!issue__c.Issue_Description__c}</td><td></td>
        </tr>
        <tr>
            <td>Date of Bid Sale</td>
            <td><apex:outputText value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!Issue__c.Date_of_Bid_Sale__c}"/></apex:outputText></td>
            <td></td>
        </tr>
        <tr>
            <td>Is the Issue subject to 15c2-12?</td>
            <td>{!issue__c.Is_the_Issue_subject_to_15c2_12__c}</td>
            <td></td>
        </tr>


        <tr>
            <td>Name</td>
            <td>{!Firm.name}</td>
        </tr>


        <p>Audited Financials and Operating Data</p>
        <apex:pageBlock>
            <apex:pageBlockTable value="{!finFilings}" var="fFile" >
                <apex:column value ="{!fFile.name}" HeaderValue="Filing"/>
                <apex:column value ="{!fFile.Filing_Name__c}" HeaderValue="Year"/>
                <apex:column value ="{!fFile.Date_rating_required__c}" HeaderValue="Date Required"/>
                <apex:column value ="{!fFile.Date_financials_filed__c}" HeaderValue="Date Financials Filed"/>
                <apex:column value ="{!fFile.Finding__c}" HeaderValue="Finding"/>
                <apex:column value ="{!fFile.Date_Op_data_filed__c}" HeaderValue="Date Op Data Filed"/>
                <apex:column value ="{!fFile.Op_data_status__c}" HeaderValue="Finding"/>                    
            </apex:pageBlockTable>
        </apex:pageBlock>

        <p>Material Events</p>
        <apex:pageBlock>
            <apex:pageBlockTable value="{!ratFilings}" var="rFile" >
                <apex:column value ="{!rFile.name}" HeaderValue="Filing"/>
                <apex:column value ="{!rFile.Rating_change__c}" HeaderValue="Up/Downgrade"/>
                <apex:column value ="{!rFile.Date_of_change__c}" HeaderValue="Date of Change"/>
                <apex:column value ="{!rFile.Date_rating_required__c}" HeaderValue="Date Required"/>
                <apex:column value ="{!rFile.Date_filed__c}" HeaderValue="Date Financials Filed"/>
                <apex:column value ="{!rFile.Rating_finding__c}" HeaderValue="Finding"/>
            </apex:pageBlockTable>
        </apex:pageBlock>

    </body>
</html>

APEX

public with sharing class FICMSummaryPDFController 
{
    public Issue__c issue { get; private set; }
    public account firm { get; private set; }
    public List <Filing__c> finFilings { get; private set; }
    public List <Filing__c> ratFilings { get; private set; }

    public FICMSummaryPDFController(ApexPages.StandardController controller)
    {

        issue = (Issue__c)controller.getRecord();

        firm = [SELECT Name,(SELECT ID from FinancialFilings__r) from account where ID = :issue.issuer_name__c];

        finFilings = [select Filing_Name__c, Date_rating_required__c, Date_financials_filed__c, Finding__c, 
                      Date_Op_data_filed__c, Op_data_status__c, id, name 
                      from filing__c where issuer__c = :issue.issuer_name__c order by filing_name__c desc]; 

        ratFilings = [select Rating_change__c, Date_of_Change__c, Date_Rating_required__c, Date_filed__c, Rating_finding__c, id, name 
                      from filing__c where rating_issuer__c = :issue.issuer_name__c order by filing_name__c desc]; 

    }
}
  • 1
    1) You should really move this as an edit to the original question as Uwe provided the answer; and 2) a better long-term design would be to do the SOQL in the getters for each List<Filing__c> - this way if any updates are done, you are refreshing the latest version of the lists; it also means the controller can be reused for other pages and hence the constructor doesn't fetch anything; only pages that reference a given controller property will fetch the records. – cropredy Mar 31 '15 at 1:05
  • Thanks @crop1645 I'm never sure if significant updates should be added to a thread or if a new question is needed. As far as your answer, I don't understand? – HomerJ Mar 31 '15 at 10:21
0

In addition to @uweheim answer, your controller would be better constructed as:

public with sharing class FICMSummaryPDFController {
 public Issue__c issue { get; private set; }
 public account firm { 
  get{  return [SELECT Name,(SELECT ID from FinancialFilings__r) 
                  from account where ID = :this.issue.issuer_name__c];}
  private set; }
 public List <Filing__c> finFilings {
   get {return [select Filing_Name__c, Date_rating_required__c,
                       Date_financials_filed__c, Finding__c, 
                       Date_Op_data_filed__c, Op_data_status__c, id, name 
                  from filing__c 
                  where issuer__c = :this.issue.issuer_name__c
                  order by filing_name__c desc];}
   private set; }
 public List <Filing__c> ratFilings { 
    get {[select Rating_change__c, Date_of_Change__c, 
                 Date_Rating_required__c, Date_filed__c, Rating_finding__c,
                 id, name 
              from filing__c 
              where rating_issuer__c = :this.issue.issuer_name__c 
              order by filing_name__c desc]; }
    private set; }

 public FICMSummaryPDFController(ApexPages.StandardController controller) {
    issue = (Issue__c)controller.getRecord();
 }
}

This is a better long-term design: Do the SOQL in the getters for each List - this way if any updates are done in page processing in the future, you are refreshing the latest version of the lists; it also means the controller can be reused for other pages and hence the constructor doesn't fetch anything that isn't needed for the page at hand, improvinf performance; only pages that reference a given controller property will fetch the records

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.