function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
foodrunnerfoodrunner 

Custome Quote PDF - How to add Product Names?

I have been working on a visualforce page for the standard quote object intended to be pdf quote page. I am having a problem with creating a list of products on the page. When I attempt to add the product name from the quote line item table, I recieve the following error about line 30.

 

Error: Unknown property 'String.product2'

 

Below is the code:

 

<apex:page standardController="Quote">
    <apex:form id="theForm"> 
   
        <apex:pageBlock >
            <apex:pageMessages />
   
            <apex:pageBlockSection title="Essential Information" columns="2"  showHeader="false">
                <apex:outputField value="{!quote.Opportunity.AccountId}" />
                <apex:outputField value="{!quote.quotenumber}" />
                <apex:outputLabel value="Bill To">
                    <apex:outputField value="{!quote.Opportunity.Account.BillingCity}" />
                    <apex:outputField value="{!quote.Opportunity.Account.BillingState}" />
                    <apex:outputField value="{!quote.Opportunity.Account.BillingPostalCode}" />
                    <apex:outputField value="{!quote.Opportunity.Account.BillingCountry}" />
                </apex:outputLabel>
                <apex:outputField value="{!quote.createdDate}" />
                <apex:inputHidden />
                <apex:outputField value="{!quote.expirationDate}" />
             </apex:pageBlockSection>
            <apex:pageBlockSection title="Contact Info" columns="2"  showHeader="true">
                <apex:outputField value="{!quote.contactid}"/>
                <apex:outputField value="{!quote.Phone}"/>
                <apex:outputField value="{!quote.email}"/>
                <apex:outputField value="{!quote.fax}"/>
             </apex:pageBlockSection>
             </apex:pageBlock>
           <apex:pageBlock title="test">
        <apex:pageBlockTable value="{!quote.Quote_Line_Item__c}" var="qli">
        <apex:dataTable value="{!qli}" var="item">
           <apex:column value="{!qli.product2}"/>*/
            <apex:column value="{!qli.Quantity}"/>
        </apex:dataTable>
        </apex:pageBlockTable>
        </apex:pageBlock>    

      </apex:form>
</apex:page>

 

How I correct this error?

Best Answer chosen by Admin (Salesforce Developers) 
SargeSarge

I guess, the child object "Quote Line Item" is  the standard object as well. Hence the value attribute of pageBlockTable should be

<apex:pageBlockTable value="{!quote.QuoteLineItems}" var="qli">

 

This must be reflected in the SOQL query like the following

 

List<Quote> quotes = [Select Id, Name, (select Id, PricebookEntryId, Pricebookentry.Name from QuoteLineItems) from Quote];

 

The inner query usually points to the plural API name.

 

And to show the product Name, use

<apex:column value="{!qli.pricebookentry.Name}"/>

 

Line items refer to junction of product and pricebook named as pricebookentry. Hence we must be refering to pricebookentry name to display the actual product name.

All Answers

SargeSarge

Hi,

 

    Can you tell me what is the data type of  "Quote_Line_Item__c" field of "quote" variable?

Since you are referring it as value attribute of pageBlockTable, I guess it should be a List of some kind. And the field name "Quote_Line_Item__c" suggests that it is a straightforward sObject field (which is supposed to be a List).

foodrunnerfoodrunner

Actually, I am trying point to the fields on the Quote Line Item object, a child object to the Quote Object. I used Quote_Line_Item__c to be able to save the file. I am Mainly interested in the Product Name field associtated with the Product record, ehich will be displayed in Quote Line Item.

 

Thank you

SargeSarge

I guess, the child object "Quote Line Item" is  the standard object as well. Hence the value attribute of pageBlockTable should be

<apex:pageBlockTable value="{!quote.QuoteLineItems}" var="qli">

 

This must be reflected in the SOQL query like the following

 

List<Quote> quotes = [Select Id, Name, (select Id, PricebookEntryId, Pricebookentry.Name from QuoteLineItems) from Quote];

 

The inner query usually points to the plural API name.

 

And to show the product Name, use

<apex:column value="{!qli.pricebookentry.Name}"/>

 

Line items refer to junction of product and pricebook named as pricebookentry. Hence we must be refering to pricebookentry name to display the actual product name.

This was selected as the best answer
foodrunnerfoodrunner

Thank you for your assistance.