• SFMani
  • NEWBIE
  • 85 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 44
    Replies
I want to create a pdf from a cutom button click and then attach it to the correspondening Object record. I have the following code for the apex controller for this:
public class attachPDFToTimeRecord {
	
	private final TimeRecords__c a; //TimeRecords object
	
	//constructor
	public attachPDFToTimeRecord(ApexPages.StandardController standardPageController) {
		a = (TimeRecords__c)standardPageController.getRecord(); //instantiate the TimeRecord object for the current record
	}
	
	//method called from the Visualforce's action attribute
	public PageReference attachPDF() {
		//generate and attach the PDF document
		PageReference pdfPage = Page.Invoice_Matter; //create a page reference to our Invoice_Matter Visualforce page
		Blob pdfBlob = pdfPage.getContent(); //get the output of the page, as displayed to a user in a browser
        
		Attachment attach = new Attachment(parentId = a.Id, Name = 'pdfAttachmentRecord.pdf', body = pdfBlob); //create the attachment object
		insert attach; //insert the attachment
		//redirect the user
		PageReference pageWhereWeWantToGo = new ApexPages.StandardController(a).view(); //we want to redirect the User back to the TimeRecord detail page
		pageWhereWeWantToGo.setRedirect(true); //indicate that the redirect should be performed on the client side
		return pageWhereWeWantToGo; //send the User on their way
	}

}

I get List has no rows for assignment to sObject error in the line
Blob pdfBlob = pdfPage.getContent();
Can anyone help my resolve this error?
 
  • March 02, 2017
  • Like
  • 0
I have a custom Object TimeRecords__c and I want to display the VF Page as a pdf in the object using a custom Button.  I created a Visualforce page and a controller class for the Custom Button. On clicking the custom button I get the 'List has no rows to SObject error'. 
My VF Page Code is as below:
<apex:page standardController="TimeRecords__c" showHeader="false" renderas="pdf" extensions="TimeRecord">

<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">


<tr>
    <td >
        <img src='{!URLFOR($Resource.VinasLogo)}'  title="logo" />
    </td>
    
    <td  align="right"><font face="Arial" >
    <b>Invoice for {!con.Name}</b>
   </font><br/>
   </td>
  
  
    
</tr>

 
<hr/>

</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>    <td><font face="Arial" >
        {!$Organization.Name}<br/>
        {!$Organization.Street}<br/>
        {!$Organization.PostalCode} {!$Organization.City}<br/>
        {!$Organization.Country}<br/>
        </font></td> 
        <td width="60%">&nbsp;</td>
   <!--<td ><font face="Arial">Invoice number: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.name}</apex:repeat></font><br/>
  
   
   <font face="Arial">Invoice Date: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.Invoice_Date__c}  </apex:repeat></font></td>-->
 
   
  
</tr>
</table>
<br/>
<hr/>
<p><b><font face="Arial" color="#000080">Address Information</font></b></p>

<table border="0" width="100%" id="table2">


<tr>
       <td>          
           <font face="Arial">Bill To:<br/>
                             {!con.MailingStreet}<br/>
                             {!con.MailingCity}{!con.MailingState}{!con.MailingPostalCode}<br/>
                                                          
           </font>
        </td>
        <td width="50%"></td>        
</tr>


</table>
<br/>
<hr/>
<p>&nbsp;</p>
<hr/>
<p align="center"><font face="Arial"><i>Copyright {!$Organization.Name}.</i></font></p>
</apex:page>

Controller Class:
global with sharing class TimeRecord {

    

     public Contact con{get;set;}
    public TimeRecords__c TR{get;set;}
    
    
   
    
    public TimeRecord(ApexPages.StandardController cntrl){
        
     
       this.TR = (TimeRecords__c) cntrl.getRecord();
        TR=[SELECT Billable__c, Activity__c, Client__c, Client_Name__c,Date_of_Work__c, Entry_Type__c, Exclude_From_Invoice__c, Fees_Time__c, Matter__c, Overtime__c, Private_Description__c, Rate__c FROM TimeRecords__c WHERE Name=: ApexPages.currentPage().getParameters().get('id') ];
        
        con=[SELECT Id, Name, MailingStreet, MailingCity, MailingState, MailingPostalCode FROM Contact ];
       
   
    }
    
}

Could someone of you folks help me sort out this error. I have tried many solutions but they don't seem to work.
Thanks in Advance.
  • February 21, 2017
  • Like
  • 0

I have a custom controller CustomInv. The Code for this is as below: 

public with sharing class CustomInv {
        public Opportunity opp{get;set;}
    
        public  List<npe01__OppPayment__c>  Rec {get; set;}
        public List<Contact> Contact {get; set;}
        public List<Contact> Contact1 {get; set;}
        public List<Contact> Contact2 {get; set;}
        
        ApexPages.StandardController standrdCntrl;
              
        
        public CustomInv(ApexPages.StandardController cntrl){
             standrdCntrl=cntrl;
             this.opp = (Opportunity) standrdCntrl.getRecord();
              
           Contact = [SELECT Name, AccountId FROM Contact WHERE  AccountId=: opp.AccountId and (Title='Primary_M' or Title='Primary_D')  limit 1] ;
           Contact1 = [SELECT Name, AccountId FROM Contact WHERE  AccountId=: opp.AccountId and (Title='Primary_M')  limit 1] ;
           Contact2 = [SELECT Name, AccountId FROM Contact WHERE  AccountId=: opp.AccountId and (Title='Primary_D')  limit 1] ;
             Rec =[Select CreatedDate, SystemModstamp,npe01__Payment_Amount__c, npe01__Opportunity__c, npe01__Paid__c, npe01__Scheduled_Date__c FROM npe01__OppPayment__c WHERE npe01__Paid__c = true and  npe01__Opportunity__c = : ApexPages.currentPage().getParameters().get('id') limit 200];
     

}
}

I am using this controller in a Visualforce Component CustComp.vfc with the code:

<apex:component controller="CustomInv" access="global">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>
    <td>
        <img src='{!URLFOR($Resource.Logo4567687)}' title="logo" />
        
    </td>
    <p align="center"><font face="Arial"><i>{!$Organization.Name}</i></font><br/>
    <font face="Arial"><i>{!$Organization.Street}</i></font><br/>
    <font face="Arial"><i>{!$Organization.City}</i></font>
    <font face="Arial"><i>,{!$Organization.State}</i></font>
    <font face="Arial"><i>{!$Organization.PostalCode}</i></font></p>
    <!--<td  align="right"><font face="Arial" >
    <b>Invoice for {!Opportunity.Account.Name}</b></font><br/>
   </td>-->
   
  
    
</tr>

<hr/>

</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>    <td width="65%"><font face="Arial" >
        Federal Tax ID: 27-0580207<br/>
        </font></td> 
        <!--<td width="50%">&nbsp;</td>-->
   <td width="50%"><font face="Arial">Invoice number: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.name}</apex:repeat></font><br/>
  
   
   <font face="Arial">Invoice Date: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.Invoice_Date__c} </apex:repeat></font></td>
 
   
  
</tr>
</table>

<br/>
<hr/>
<p><b><font face="Arial" color="#000080">Account Information</font></b></p>

<table border="0" width="100%" id="table2">
<tr>
       <td colspan="3">
           <font face="Arial">Child name: {!Opportunity.Account.Name} <br/><br/></font>
       </td>
</tr>
Parent Name:
<!--<apex:dataList value="{!Contact}" var="con">

<tr>
       <td>          
           <font face="Arial"> {!con.Name}<br/>
                             {!Opportunity.Account.BillingStreet}<br/>
                             {!Opportunity.Account.BillingPostalCode} {!Opportunity.Account.BillingCity}
           </font>
        </td>
        
</tr> 
 </apex:dataList> -->
<!-- <apex:repeat value="{!Contact}" var="con">-->

<apex:repeat value="{!Contact1}" var="con1">

<apex:repeat value="{!Contact2}" var="con2">
<tr>
       <td colspan="3">          
           <font face="Arial"> {!IF(((Opportunity.Description=='Mother')||(Opportunity.Description=='mother')||(Opportunity.Description=='Mom')||(Opportunity.Description=='mom')),con1.Name,IF((Opportunity.Description=='Father')||(Opportunity.Description=='father')||(Opportunity.Description=='Dad')||(Opportunity.Description=='dad'),con2.Name, 'con.Name'))}<br/>
                            
                             {!Opportunity.Account.BillingStreet}<br/>
                             {!Opportunity.Account.BillingPostalCode} {!Opportunity.Account.BillingCity}
           </font>
        </td>
        
</tr> 

</apex:repeat>
</apex:repeat>

</table>
<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Invoice Detail</font></b></p>
<table border="0" width="100%" id="table4">
<tr>
    <td bgcolor="#C0C0C0"><font face="Arial">Item</font></td>
    <td bgcolor="#C0C0C0"><font face="Arial">Description</font></td>
    <td bgcolor="#C0C0C0"><font face="Arial">List Price</font></td>
    <td bgcolor="#C0C0C0"><font face="Arial">Qty</font></td>
    <td bgcolor="#C0C0C0"><font face="Arial">Total Price</font></td>
</tr>

<tr>
       <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
       
          <tr>
              <td>{!line.PricebookEntry.Name}</td>
              <td>{!line.Description}</td>
              <td>{!line.ListPrice}</td>
              <td>{!line.Quantity}</td>
              <td><apex:OutputField value="{!line.SubTotal_Price__c}"/></td>
          </tr>
       </apex:repeat>
</tr>

<tr>
        
       <td bgcolor="#C0C0C0" align="right" colspan="4">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Opportunity.Total_Amount__c}"/></font></td>
</tr>

</table>
<table border="0" width="100%" id="table4">
<tr>
       <td bgcolor="#C0C0C0"><font face="Arial">Post Date</font></td> 
       <td bgcolor="#C0C0C0"><font face="Arial">Due Date</font></td>        
       <!--<td bgcolor="#C0C0C0"><font face="Arial">Description</font></td>  -->  
       <td bgcolor="#C0C0C0"><font face="Arial">Credit</font></td>
       <!--<td bgcolor="#C0C0C0"><font face="Arial">Debit</font></td>  -->    
</tr>
   <apex:variable value="{!1}" var="rowNum"/>
     <apex:repeat value="{!Rec}" var="Pay">
         <tr>
           
             <td> {!Pay.npe01__Scheduled_Date__c}
             <apex:variable var="rowNum" value="{!rowNum + 1}"  /></td>
             <td>{!Pay.npe01__Scheduled_Date__c}</td>             
             <!--<td>{!line.Description}</td> -->                       
             <td><apex:OutputField value="{!Pay.npe01__Payment_Amount__c}"/></td>
             <!--<apex:variable value="{!Opportunity.Amount}" var="amt"/>
             <apex:variable value="{!Pay.npe01__Payment_Amount__c}" var="pmt"/>
             <td><apex:variable value="{!(amt-pmt)}" var="debit1"/>
             <apex:variable value="{!((-pmt*(rowNum-2))-pmt)}" var="debit2"/>
             
             $<apex:outputText value="{!debit1}"/></td>-->
             
          </tr>
        </apex:repeat>
 
      <tr>
        
       <td bgcolor="#C0C0C0" align="right" colspan="2">
       <font face="Arial"><b>Total Credit:</b>&nbsp;<apex:OutputField value="{!Opportunity.npe01__Payments_Made__c}"/></font></td>
       <td bgcolor="#C0C0C0" align="right" colspan="4">
       <font face="Arial"><b>Balance:</b>&nbsp;<apex:OutputField value="{!Opportunity.Balance_Remaining__c}"/></font></td>
</tr> 
         


</table>
<br/>
<hr/>

<p align="center"><font face="Arial"><i>Copyright {!$Organization.Name}.</i></font></p>
</apex:component>


I need to use this VF Component in a Visualforce  Email Template..

But I get the error Unknown constructor 'CustomInv.CustomInv()' in CustComp.vfc 

I am unable to identify why it gives this error. Can someone please help?
 

  • March 15, 2016
  • Like
  • 0
Everytime I try to deploy any code from sandbox to production if gives the error failed with two test classes failing within the organisation, the test classes are tom_test_status_changes and tom_test_status_changes. Even on running these classes itself in the production the test fails.

The error message it gives is System.DmlException: Update failed. First exception on row 0 with id a0WG000000LAcROMA1; first error: TRANSFER_REQUIRES_READ, The new owner must have read permission: [] for both the test classes. I tried the solutions given on other threads with similar problem to check for owner permissions and also removing the with sharing keyword in the apex class. Still the problem persists.

I would really appreciate if anyone of you geeks can help me solve the problem. It is really urgent as I need to immediately deploy the new updates to the organisation. 
  • March 09, 2016
  • Like
  • 0
I am getting a constructor not defined error in Apex class when I make a List of the custom object.
Here is my code:

public with sharing class Receivable_Opp {
    public ApexPages.StandardController myRecController{get;set;}
    public  List<npe01__OppPayment__c>  Rec {get; set;}
    
    
     public ApexPages.StandardController standardOppController;
     
    
       public Receivable_Opp(ApexPages.StandardController cntrl){
           standardOppController = cntrl;
           Opportunity opp = (Opportunity)cntrl.getRecord();
          
           Rec = [Select CreatedDate, SystemModstamp, npe01__Opportunity__c, npe01__Paid__c, npe01__Scheduled_Date__c FROM npe01__OppPayment__c WHERE npe01__Paid__c = true and npe01__Opportunity__c = :opp.Id limit 1];
           myRecController = new ApexPages.StandardController(Rec);       
  }
   
}

If someone can help me resolve the issue, it would be of great help. Thanks. 
  • August 27, 2015
  • Like
  • 0
I have a custom object Payment(npe01__OppPayment__c). on the Opportunity page from related list Payment, I am trying to access a field Schedule Date. But it gives me Unknown property 'OpportunityStandardController.npe01__OppPayment__c' error on the Visualforce page. Below are my apex and visualforce code.

Apex Code:
public with sharing class Receivable_Opp {
    public ApexPages.StandardController myRecController{get;set;}
    public  npe01__OppPayment__c  Rec {get; set;}

     public ApexPages.StandardController standardOppController;
    
       public Receivable_Opp(ApexPages.StandardController cntrl){
           standardOppController = cntrl;
           Opportunity opp = (Opportunity)cntrl.getRecord();
           Rec = [Select npe01__Scheduled_Date__c FROM npe01__OppPayment__c  WHERE npe01__Paid__c = true ] ;
           myRecController = new ApexPages.StandardController(Rec);    
        
    }
}

Visualforce Code:
<apex:page standardController="Opportunity" showHeader="false" renderas="pdf" extensions="contact_opp,Receivable_Opp">

<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>
    <td>
        <img src='{!URLFOR($Resource.Logo4567687)}' title="logo" />
        
    </td>
    <p align="center"><font face="Arial"><i>{!$Organization.Name}</i></font><br/>
    <font face="Arial"><i>{!$Organization.Street}</i></font><br/>
    <font face="Arial"><i>{!$Organization.City}</i></font>
    <font face="Arial"><i>,{!$Organization.State}</i></font>
    <font face="Arial"><i>{!$Organization.PostalCode}</i></font></p>
    <!--<td  align="right"><font face="Arial" >
    <b>Invoice for {!Opportunity.Account.Name}</b></font><br/>
   </td>-->
   
  
    
</tr>

<hr/>

</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>    <td width="65%"><font face="Arial" >
        Federal Tax ID: 27-0580207<br/>
        </font></td> 
        <!--<td width="50%">&nbsp;</td>-->
   <td width="50%"><font face="Arial">Invoice number: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.name}</apex:repeat></font><br/>
  
   
   <font face="Arial">Invoice Date: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.Invoice_Date__c} </apex:repeat></font></td>
 
   
  
</tr>
</table>

<br/>
<hr/>
<p><b><font face="Arial" color="#000080">Address Information</font></b></p>

<table border="0" width="100%" id="table2">
<tr>
       <td colspan="3">
           <font face="Arial">Child name: {!Opportunity.Account.Name} <br/><br/></font>
       </td>
</tr>
<tr>
       <td>          
           <font face="Arial">{!Contact.Name}<br/>
                             {!Opportunity.Account.BillingStreet}<br/>
                             {!Opportunity.Account.BillingPostalCode} {!Opportunity.Account.BillingCity}
           </font>
        </td>
        <!--<td width="50%"></td>
        <td >
           <font face="Arial">Ship To:<br/>
                              {!Opportunity.Account.ShippingStreet}<br/>
                              {!Opportunity.Account.ShippingPostalCode} {!Opportunity.Account.ShippingCity}
           </font>
        </td>-->
</tr>    
</table>
<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Invoice Detail</font></b></p>
<table border="0" width="100%" id="table4">
<tr>
       <td bgcolor="#C0C0C0"><font face="Arial">Post Date</font></td> 
       <td bgcolor="#C0C0C0"><font face="Arial">Due Date</font></td> 
       <td bgcolor="#C0C0C0"><font face="Arial">Item</font></td>
       <!--<td bgcolor="#C0C0C0"><font face="Arial">Description</font></td>  -->  
       <td bgcolor="#C0C0C0"><font face="Arial">Credit</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Debit</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Total Price</font></td>
</tr>
<tr>
       <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
       
          <tr>
             <td>{!npe01__OppPayment__c.npe01__Scheduled_Date__c }</td>
             <td>{!npe01__OppPayment__c.npe01__Scheduled_Date__c }</td>
             <td>{!line.PricebookEntry.Name}</td>
             <!--<td>{!line.Description}</td> -->                       
             <td>{!Opportunity.npe01__Payments_Made__c}</td>
             <td>{!Opportunity.npe01__Amount_Outstanding__c}</td>
             <td><apex:OutputField value="{!line.TotalPrice}"/></td>
          </tr>
       </apex:repeat>
         
</tr>
<tr>
        
       <td bgcolor="#C0C0C0" align="right" colspan="6">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Opportunity.Amount}"/></font></td>
</tr>
</table>
<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Terms and Conditions</font></b></p>
<table border="0" width="100%" id="table3">
<tr>
        
       
        <td><font face="Arial">
              Payment Method:&nbsp;<apex:OutputField value="{!Opportunity.QuotePaymentMode__c}"/><br/>
              Payment Terms:&nbsp; <apex:OutputField value="{!Opportunity.QuotePaymentTime__c}"/><br/>
              Billing Frequency:&nbsp; <apex:OutputField value="{!Opportunity.QuoteBillingFrequency__c}"/><br/>
            </font>
       </td>
</tr>
</table>
<br/>
<p><font face="Arial">{!Opportunity.Conditions__c}</font></p>
<br/>
<hr/>
<table width="100%" id="table5">
Special Terms:
</table>
<p>&nbsp;</p>
<hr/>
<p align="center"><font face="Arial"><i>Copyright {!$Organization.Name}.</i></font></p>
</apex:page>

Could someone please indicate the error. Would be very thankful.
  • August 26, 2015
  • Like
  • 0
I need help in creating a trigger which can automatically generate an invoice when an opportunity is created with the amount field filled.
  • August 06, 2015
  • Like
  • 0

 

Hello Board,

 

I am trying to add the values from the AggregateList to another list, but I get the following error:

 

Error: Controller Compile Error: Invalid initial expression type for field Parent, expecting: SOBJECT:Account (or single row query result of that type)

 

Here is my code:

 

List<AggregateResult> agr=[select id ID,Parent.id GrandParent, sum(Total_Service_Collections__c) totalserv from
                                    Account where id in:accIds group by id,Parent.id];


        List<Account> AccountList = new List<Account>(); 
                       
        for(AggregateResult a:agr)
        { 
           ID AId= string.valueOf(a.get('ID'));
           ID parent=string.valueOf(a.get('GrandParent'));
           
           Account acc=new Account(ID=AId,Parent=parent); // Error in this line
           acc.CountPick__c=double.valueOf(a.get('totalserv'));
          
           AccountList.add(acc);
         
          
        }

 

I would appreciate if someone can help me out on how to resolve the problem.

 

Thanks.

  • September 05, 2012
  • Like
  • 0

Hello Board,

 

I am trying to add the values from the AggregateList to another list, but I get the following error:

 

Error: Controller Compile Error: Invalid initial expression type for field Parent, expecting: SOBJECT:Account (or single row query result of that type)

 

Here is my code:

 

List<AggregateResult> agr=[select id ID,Parent.id GrandParent, sum(Total_Service_Collections__c) totalserv from
                                    Account where id in:accIds group by id,Parent.id];
        List<Account> AccountList = new List<Account>(); 
                       
        for(AggregateResult a:agr)
        { 
           ID AId= string.valueOf(a.get('ID'));
           ID parent=string.valueOf(a.get('GrandParent'));
           
          Account acc=new Account(ID=AId,Parent=parent); // Error in This line
           acc.CountPick__c=double.valueOf(a.get('totalserv'));
          
           AccountList.add(acc);
         
          
        }

 

I would appreciate if someone can help me out on how to resolve the problem.

 

Thanks.

  • September 05, 2012
  • Like
  • 0

 I am looking forward to integrate a virtual phone system within salesforce, which should be able to embed click-to-dial into salesforce. Does anyone have an idea on how to implement it?

I want to create a pdf from a cutom button click and then attach it to the correspondening Object record. I have the following code for the apex controller for this:
public class attachPDFToTimeRecord {
	
	private final TimeRecords__c a; //TimeRecords object
	
	//constructor
	public attachPDFToTimeRecord(ApexPages.StandardController standardPageController) {
		a = (TimeRecords__c)standardPageController.getRecord(); //instantiate the TimeRecord object for the current record
	}
	
	//method called from the Visualforce's action attribute
	public PageReference attachPDF() {
		//generate and attach the PDF document
		PageReference pdfPage = Page.Invoice_Matter; //create a page reference to our Invoice_Matter Visualforce page
		Blob pdfBlob = pdfPage.getContent(); //get the output of the page, as displayed to a user in a browser
        
		Attachment attach = new Attachment(parentId = a.Id, Name = 'pdfAttachmentRecord.pdf', body = pdfBlob); //create the attachment object
		insert attach; //insert the attachment
		//redirect the user
		PageReference pageWhereWeWantToGo = new ApexPages.StandardController(a).view(); //we want to redirect the User back to the TimeRecord detail page
		pageWhereWeWantToGo.setRedirect(true); //indicate that the redirect should be performed on the client side
		return pageWhereWeWantToGo; //send the User on their way
	}

}

I get List has no rows for assignment to sObject error in the line
Blob pdfBlob = pdfPage.getContent();
Can anyone help my resolve this error?
 
  • March 02, 2017
  • Like
  • 0
I have a custom Object TimeRecords__c and I want to display the VF Page as a pdf in the object using a custom Button.  I created a Visualforce page and a controller class for the Custom Button. On clicking the custom button I get the 'List has no rows to SObject error'. 
My VF Page Code is as below:
<apex:page standardController="TimeRecords__c" showHeader="false" renderas="pdf" extensions="TimeRecord">

<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">


<tr>
    <td >
        <img src='{!URLFOR($Resource.VinasLogo)}'  title="logo" />
    </td>
    
    <td  align="right"><font face="Arial" >
    <b>Invoice for {!con.Name}</b>
   </font><br/>
   </td>
  
  
    
</tr>

 
<hr/>

</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>    <td><font face="Arial" >
        {!$Organization.Name}<br/>
        {!$Organization.Street}<br/>
        {!$Organization.PostalCode} {!$Organization.City}<br/>
        {!$Organization.Country}<br/>
        </font></td> 
        <td width="60%">&nbsp;</td>
   <!--<td ><font face="Arial">Invoice number: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.name}</apex:repeat></font><br/>
  
   
   <font face="Arial">Invoice Date: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.Invoice_Date__c}  </apex:repeat></font></td>-->
 
   
  
</tr>
</table>
<br/>
<hr/>
<p><b><font face="Arial" color="#000080">Address Information</font></b></p>

<table border="0" width="100%" id="table2">


<tr>
       <td>          
           <font face="Arial">Bill To:<br/>
                             {!con.MailingStreet}<br/>
                             {!con.MailingCity}{!con.MailingState}{!con.MailingPostalCode}<br/>
                                                          
           </font>
        </td>
        <td width="50%"></td>        
</tr>


</table>
<br/>
<hr/>
<p>&nbsp;</p>
<hr/>
<p align="center"><font face="Arial"><i>Copyright {!$Organization.Name}.</i></font></p>
</apex:page>

Controller Class:
global with sharing class TimeRecord {

    

     public Contact con{get;set;}
    public TimeRecords__c TR{get;set;}
    
    
   
    
    public TimeRecord(ApexPages.StandardController cntrl){
        
     
       this.TR = (TimeRecords__c) cntrl.getRecord();
        TR=[SELECT Billable__c, Activity__c, Client__c, Client_Name__c,Date_of_Work__c, Entry_Type__c, Exclude_From_Invoice__c, Fees_Time__c, Matter__c, Overtime__c, Private_Description__c, Rate__c FROM TimeRecords__c WHERE Name=: ApexPages.currentPage().getParameters().get('id') ];
        
        con=[SELECT Id, Name, MailingStreet, MailingCity, MailingState, MailingPostalCode FROM Contact ];
       
   
    }
    
}

Could someone of you folks help me sort out this error. I have tried many solutions but they don't seem to work.
Thanks in Advance.
  • February 21, 2017
  • Like
  • 0

I have a custom controller CustomInv. The Code for this is as below: 

public with sharing class CustomInv {
        public Opportunity opp{get;set;}
    
        public  List<npe01__OppPayment__c>  Rec {get; set;}
        public List<Contact> Contact {get; set;}
        public List<Contact> Contact1 {get; set;}
        public List<Contact> Contact2 {get; set;}
        
        ApexPages.StandardController standrdCntrl;
              
        
        public CustomInv(ApexPages.StandardController cntrl){
             standrdCntrl=cntrl;
             this.opp = (Opportunity) standrdCntrl.getRecord();
              
           Contact = [SELECT Name, AccountId FROM Contact WHERE  AccountId=: opp.AccountId and (Title='Primary_M' or Title='Primary_D')  limit 1] ;
           Contact1 = [SELECT Name, AccountId FROM Contact WHERE  AccountId=: opp.AccountId and (Title='Primary_M')  limit 1] ;
           Contact2 = [SELECT Name, AccountId FROM Contact WHERE  AccountId=: opp.AccountId and (Title='Primary_D')  limit 1] ;
             Rec =[Select CreatedDate, SystemModstamp,npe01__Payment_Amount__c, npe01__Opportunity__c, npe01__Paid__c, npe01__Scheduled_Date__c FROM npe01__OppPayment__c WHERE npe01__Paid__c = true and  npe01__Opportunity__c = : ApexPages.currentPage().getParameters().get('id') limit 200];
     

}
}

I am using this controller in a Visualforce Component CustComp.vfc with the code:

<apex:component controller="CustomInv" access="global">
    <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>
    <td>
        <img src='{!URLFOR($Resource.Logo4567687)}' title="logo" />
        
    </td>
    <p align="center"><font face="Arial"><i>{!$Organization.Name}</i></font><br/>
    <font face="Arial"><i>{!$Organization.Street}</i></font><br/>
    <font face="Arial"><i>{!$Organization.City}</i></font>
    <font face="Arial"><i>,{!$Organization.State}</i></font>
    <font face="Arial"><i>{!$Organization.PostalCode}</i></font></p>
    <!--<td  align="right"><font face="Arial" >
    <b>Invoice for {!Opportunity.Account.Name}</b></font><br/>
   </td>-->
   
  
    
</tr>

<hr/>

</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>    <td width="65%"><font face="Arial" >
        Federal Tax ID: 27-0580207<br/>
        </font></td> 
        <!--<td width="50%">&nbsp;</td>-->
   <td width="50%"><font face="Arial">Invoice number: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.name}</apex:repeat></font><br/>
  
   
   <font face="Arial">Invoice Date: <apex:repeat value="{!Opportunity.Invoices__r}" var="line2">
   {!line2.Invoice_Date__c} </apex:repeat></font></td>
 
   
  
</tr>
</table>

<br/>
<hr/>
<p><b><font face="Arial" color="#000080">Account Information</font></b></p>

<table border="0" width="100%" id="table2">
<tr>
       <td colspan="3">
           <font face="Arial">Child name: {!Opportunity.Account.Name} <br/><br/></font>
       </td>
</tr>
Parent Name:
<!--<apex:dataList value="{!Contact}" var="con">

<tr>
       <td>          
           <font face="Arial"> {!con.Name}<br/>
                             {!Opportunity.Account.BillingStreet}<br/>
                             {!Opportunity.Account.BillingPostalCode} {!Opportunity.Account.BillingCity}
           </font>
        </td>
        
</tr> 
 </apex:dataList> -->
<!-- <apex:repeat value="{!Contact}" var="con">-->

<apex:repeat value="{!Contact1}" var="con1">

<apex:repeat value="{!Contact2}" var="con2">
<tr>
       <td colspan="3">          
           <font face="Arial"> {!IF(((Opportunity.Description=='Mother')||(Opportunity.Description=='mother')||(Opportunity.Description=='Mom')||(Opportunity.Description=='mom')),con1.Name,IF((Opportunity.Description=='Father')||(Opportunity.Description=='father')||(Opportunity.Description=='Dad')||(Opportunity.Description=='dad'),con2.Name, 'con.Name'))}<br/>
                            
                             {!Opportunity.Account.BillingStreet}<br/>
                             {!Opportunity.Account.BillingPostalCode} {!Opportunity.Account.BillingCity}
           </font>
        </td>
        
</tr> 

</apex:repeat>
</apex:repeat>

</table>
<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Invoice Detail</font></b></p>
<table border="0" width="100%" id="table4">
<tr>
    <td bgcolor="#C0C0C0"><font face="Arial">Item</font></td>
    <td bgcolor="#C0C0C0"><font face="Arial">Description</font></td>
    <td bgcolor="#C0C0C0"><font face="Arial">List Price</font></td>
    <td bgcolor="#C0C0C0"><font face="Arial">Qty</font></td>
    <td bgcolor="#C0C0C0"><font face="Arial">Total Price</font></td>
</tr>

<tr>
       <apex:repeat value="{!Opportunity.OpportunityLineItems}" var="line">
       
          <tr>
              <td>{!line.PricebookEntry.Name}</td>
              <td>{!line.Description}</td>
              <td>{!line.ListPrice}</td>
              <td>{!line.Quantity}</td>
              <td><apex:OutputField value="{!line.SubTotal_Price__c}"/></td>
          </tr>
       </apex:repeat>
</tr>

<tr>
        
       <td bgcolor="#C0C0C0" align="right" colspan="4">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Opportunity.Total_Amount__c}"/></font></td>
</tr>

</table>
<table border="0" width="100%" id="table4">
<tr>
       <td bgcolor="#C0C0C0"><font face="Arial">Post Date</font></td> 
       <td bgcolor="#C0C0C0"><font face="Arial">Due Date</font></td>        
       <!--<td bgcolor="#C0C0C0"><font face="Arial">Description</font></td>  -->  
       <td bgcolor="#C0C0C0"><font face="Arial">Credit</font></td>
       <!--<td bgcolor="#C0C0C0"><font face="Arial">Debit</font></td>  -->    
</tr>
   <apex:variable value="{!1}" var="rowNum"/>
     <apex:repeat value="{!Rec}" var="Pay">
         <tr>
           
             <td> {!Pay.npe01__Scheduled_Date__c}
             <apex:variable var="rowNum" value="{!rowNum + 1}"  /></td>
             <td>{!Pay.npe01__Scheduled_Date__c}</td>             
             <!--<td>{!line.Description}</td> -->                       
             <td><apex:OutputField value="{!Pay.npe01__Payment_Amount__c}"/></td>
             <!--<apex:variable value="{!Opportunity.Amount}" var="amt"/>
             <apex:variable value="{!Pay.npe01__Payment_Amount__c}" var="pmt"/>
             <td><apex:variable value="{!(amt-pmt)}" var="debit1"/>
             <apex:variable value="{!((-pmt*(rowNum-2))-pmt)}" var="debit2"/>
             
             $<apex:outputText value="{!debit1}"/></td>-->
             
          </tr>
        </apex:repeat>
 
      <tr>
        
       <td bgcolor="#C0C0C0" align="right" colspan="2">
       <font face="Arial"><b>Total Credit:</b>&nbsp;<apex:OutputField value="{!Opportunity.npe01__Payments_Made__c}"/></font></td>
       <td bgcolor="#C0C0C0" align="right" colspan="4">
       <font face="Arial"><b>Balance:</b>&nbsp;<apex:OutputField value="{!Opportunity.Balance_Remaining__c}"/></font></td>
</tr> 
         


</table>
<br/>
<hr/>

<p align="center"><font face="Arial"><i>Copyright {!$Organization.Name}.</i></font></p>
</apex:component>


I need to use this VF Component in a Visualforce  Email Template..

But I get the error Unknown constructor 'CustomInv.CustomInv()' in CustComp.vfc 

I am unable to identify why it gives this error. Can someone please help?
 

  • March 15, 2016
  • Like
  • 0