I am having an Invoice Layout and adding the Products as follows using the Visual Force page:

Quantity, Product Code, Product Description, Unit Price ,Net Amount, VAT
1,        S5KGC,        5Kg CO2 Service,     £2.98,      £2.98,      £0.60
2,        S5KGCX,       5Kg CO2 Exchanged,   £86.71,     £173.42
5,        H7792,        5Kg CO2 New,         £205.23,    £1,026.15
4,        H9264,        2Kg CO2 New,.        £125.75,    £503.00
3,        C2KGC,        2Kg CO2 Condemned,   £0.00,      £0.00 ,     £0.00
6,        H7792,        5Kg CO2 New.,        £205.23,    £1,231.38
12,       H9264,        2Kg CO2 New,         £125.75 ,   £1,509.00
3,        C5KGC,        5Kg CO2 Condemned,   £0.00,      £0.00,      £0.00
4,        S5KGCR,       5Kg CO2 Re Charged,  £36.80,     £147.20,    £29.44
1,        S2KGC,        2Kg CO2 Service,     £2.98       £2.98,      £0.60
2,        S2KGCX,       2Kg CO2 Exchanged,   £69.97 ,    £139.94
5,        S2KGCR,       2Kg CO2 Re Charged , £25.33,     £126.65

Visual force page: ....... ........
Quantity Product Code Product Description Unit Price Net Amount VAT

  <apex:repeat value="{!relatedTo.OpportunityLineItems}" var="line">
          <td class = "normal"><apex:outputText value="{0,number, ##,###,###0}"><apex:param value="{!line.Quantity}"/></apex:outputText></td>
          <td class = "normal">{!line.PricebookEntry.Product2.SAGE_Code__c}</td>
          <td class = "normal">{!line.PricebookEntry.Name}{!if(ISNULL(line.Description),'', ' - '&line.Description)}</td>
          <td align = "right"><b><apex:outputText value="{0,number,£##,##,##,##0.00}"><apex:param value="{!line.UnitPrice}"/></apex:outputText></b></td>
          <td align = "right"><b><apex:outputText value="{0,number,£##,##,##,##0.00}"><apex:param value="{!line.TotalPrice}"/></apex:outputText></b></td>
          <td align = "right"><b><apex:outputText value="{0,number,£##,##,##,##0.00}"><apex:param value="{!line.VAT__c}"/></apex:outputText></b></td>

I want to sort them into categories like Service, Condemned, Re Charged, New... in the Layout, Can any one help me how can I achieve this.

  • Have you looked that the visualforce dataTable component ? Know any html can be used in your visualforce page too. – Samuel De Rycke Oct 28 '14 at 9:42
  • Thanks for your reply Sam, with their end text of the Product Name I want to sort them , How can I use the HTML to do this – Karti K Oct 28 '14 at 9:46
  • I'm unclear whether this page is being populated from the DB by SOQL and Apex? Standard controller? Is this data being entered by a user? Is this data being uploaded from a flat file? It also looks like the data you want to sort by...some kind of category...doesn't exist as a separate field, which will make the sort you want difficult. – pchittum Oct 28 '14 at 9:53
  • Sorry Peter, It is an Email Template Where I used relatedToType <messaging:emailTemplate recipientType="Contact" relatedToType="Opportunity"> </messaging:emailTemplate> – Karti K Oct 28 '14 at 10:43
  • 2
    I think you're going to need to create custom a controller that sorts your products for you into categories before it sends them to your page. That's the only way I know of to do this. Its really no different than creating a custom quote page except that you're sending the results to an email template instead. – crmprogdev Oct 28 '14 at 16:29

Your Answer

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

Browse other questions tagged or ask your own question.