Skip to main content
Hello All ,

I am using a very simple VFP and Apex extension and getting this error where ideally it should not throw this error 

VFP :

<apex:page standardController="UAL_Customer_Services__c" extensions="UALServicesPDF" standardstylesheets="false" renderAs="pdf" applyHtmlTag="false" showHeader="false" sidebar="false">

        <apex:pageMessages ></apex:pageMessages>

    <html>

     <head> 

            <style type="text/css" media="print">          

                @page {     

                size: A4 relative;             

                margin-top:3cm;

                margin-bottom:0.5cm;

                margin-left:17px;

                margin-right:20px;

                

                @top-center {

                content: element(header);

                }

                @bottom-center {

                content: element(footer);

                }

                

                }

                 table, th, td 

                {

                border-collapse: collapse;

                }

                div.header {

                padding:5px;

                position: running(header);

                } 

                body 

                {

                font-family: Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif;//'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;

                font-weight:normal; 

                font-size:14px; 

                mso-line-height-rule: exactly;

                }

                div.footer {

                padding:5px;

                position: running(footer);

                }

                ms{

                padding:5px;

                }

            </style>

    </head>

  <body>

           <div Style="margin:2px;">

           <p style="font-size:larger;text-align:center;font-weight: bold;" >UAL INDUSTRIES LIMITED</p>

           <p style="font-size:larger;text-align:center;font-weight: bold;" >Loss Assessment for the period</p>

           <p style="font-size:larger;text-align:center;font-weight: bold;" >PRODUCT TYPE - KAILASH GOLD</p>           

           <p style="font-size:larger;text-align:center;font-weight: bold;" >STORAGE LOCATION - U101</p>

           <p style="font-size:larger;text-align:center;font-weight: bold;" >Date of Inspection - 25.06.2023</p>

           </div> 

      

       <div><table border="1" width="100%" Style="margin:2px;">

        <tr><td width="50%">DOCUMENT NO.</td><td>{!UAL_Customer_Services__c.name}</td></tr>

        <tr><td width="50%">DOCUMENT DATE </td><td><apex:outputText value="{0,date,dd'/'MM'/'yyyy}"><apex:param value="{!UAL_Customer_Services__c.Entry_Date__c}"/></apex:outputText> </td></tr>

        <tr><td width="50%">MAIN PARTY</td><td>{!UAL_Customer_Services__c.Dealer_Name__r.name}</td></tr>

        <tr><td width="50%">ADDRESS</td><td>{!UAL_Customer_Services__c.Dealer_Name__r.Address_1__c}</td></tr>     

        <tr><td width="50%">PIN CODE</td><td>{!UAL_Customer_Services__c.Dealer_Name__r.PIN_Code__c}</td></tr>

        <tr><td width="50%">STATE</td><td>{!UAL_Customer_Services__c.Dealer_Name__r.Region__c}</td></tr>

        <tr><td width="50%">Party Code</td><td>{!UAL_Customer_Services__c.Dealer_Code__c}</td></tr>

        <tr><td width="50%">ASSESSMENT TYPE</td><td>BREAKAGE LOSS ASSESSMENT</td></tr></table></div>

      

      

         <div><table border="1" width="100%"><tr>

                 <th width="20%" style="text-align:center;">Size</th>

                <th width="15%" style="text-align:center;">Input(MTR)</th>

                <th width="15%" style="text-align:center;">Input(MT)</th>

                <th width="15%" style="text-align:center;">Output(MTR)</th>

                <th width="15%" style="text-align:center;">Output(MT)</th>

                <th width="10%" style="text-align:center;">Loss(MTR)</th>

                <th width="10%" style="text-align:center;">Loss(MT)</th>

                </tr>

              <apex:repeat value="{!UalSvmstlist}" var="SvDtllist">

                  <tr>

                    <!--<td width="20%" style="text-align:center">{!SvDtllist.Size__c}</td>

                    <td width="20%" style="text-align:center">{!SvDtllist.Size__c}</td>

                    <td width="20%" style="text-align:center">{!SvDtllist.Input_MT__c}</td>

                    <td width="20%" style="text-align:center">{!SvDtllist.Available_Size_m__c}</td>

                    <td style="text-align:right;" width="20%">{!SvDtllist.Output_MT__c}</td> 

                    <td style="text-align:right;" width="20%">{!SvDtllist.Loss_MTR__c}</td> 

                    <td style="text-align:right;" width="20%">{!SvDtllist.Loss_MT__c}</td>--> 

                </tr></apex:repeat>

            </table></div>

        </body>

           </html>

APEX :

public with sharing class  UALServicesPDF {

    public Id aids {set;get;}

    LIST<UAL_Customer_Services__c> UalSvmstlist {set;get;}

    LIST<UAL_Customer_Service_Details__c> UalSvDtllist {set;get;}

                                            

    public UALServicesPDF(Apexpages.StandardController std){

      aids=Apexpages.currentPage().getParameters().get('Id');

        

      UalSvmstlist = [SELECT id, name from  UAL_Customer_Services__c where id =  :aids];

        

      UalSvDtllist = [SELECT 

                        UAL_Customer_Services__c,

                        Size__c,

                        Input_MT__c,

                        Available_Size_m__c,

                        Output_MT__c,

                        Loss_MTR__c,

                        Loss_MT__c,

                        Corrugation__c

                        FROM 

                        UAL_Customer_Service_Details__c

                        WHERE 

                        UAL_Customer_Services__r.id = :aids];

      }

}

 
3 respuestas
  1. 17 jul 2023, 09:45
    HI Debaranjan,

    Can you modify your apex class as below and see if it fixes the error:

    public with sharing class UALServicesPDF {

    public Id aids { get; set; }

    public List<UAL_Customer_Services__c> UalSvmstlist { get; private set; }

    public List<UAL_Customer_Service_Details__c> UalSvDtllist { get; private set; }

    public UALServicesPDF(Apexpages.StandardController std) {

    aids = Apexpages.currentPage().getParameters().get('Id');

    UalSvmstlist = [SELECT id, name from UAL_Customer_Services__c where id = :aids];

    UalSvDtllist = [SELECT ... FROM UAL_Customer_Service_Details__c WHERE UAL_Customer_Services__r.id = :aids];

    }

    }

    By changing private set; to public get; private set;, the UalSvmstlist property will be accessible in the Visualforce page

    Additionally, you mentioned that you tried <apex:repeat value="{!UalSvDtllist}" var="SvDtllist"> and encountered an error as well. If you face any issues with UalSvDtllist, ensure that the SELECT statement inside the Apex extension is correctly retrieving the necessary data from the UAL_Customer_Service_Details__c object.

    If this information helps, please mark the answer as best. Thank you
0/9000